if you need a socket, you have two options:
1.Instantiate QTcpSocket or QUdpSocket
//实例化
2.Create a native socket descriptor, instantiate QAbstractSocket, and call setSocketDescriptor() to wrap the
native socket.
Internally 1.在内部,内存 internally 1.在内(部) 2.内部的
QUdpSocket的连接两种方式:
1.void QAbstractSocket::connectToHost ( const QString & hostName, quint16 port, OpenMode openMode =
ReadWrite )
例:udpSocket->connectToHost("211.87.147.238",6666,QIODevice::ReadWrite);
或udpSocket->connectToHost("example.com",6666,QIODevice::ReadWrite);
2.void QAbstractSocket::connectToHost (
const QHostAddress & address, quint16 port, OpenMode openMode =
ReadWrite )
例:
QHostAddress *hostaddr;
hostaddr= new QHostAddress("211.87.147.238");//主机IP
udpSocket-