一般情况下UDP传输用writeDatagram();TCP传输数据用Write()函数
UDP传输代码:
static QUdpSocket *udpSocket = NULL; if(!udpSocket) { udpSocket = new QUdpSocket(); if(!udpSocket || !udpSocket->bind(QHostAddress("127.0.0.1"),5505)) { qDebug()<<"udp port bind fail....\n"; return; } } qint64 wc = udpSocket->writeDatagram((char*)&_tmpbuf,sizeof(_tmpbuf),QHostAddress("127.0.0.1"),5502);
发布于:2020-03-27 13:55
打赏
请登录后回答