QT UDPsocket Bind 绑定端口失败的原因的解决方案之一
作者:互联网
最近在开发Super Helpdesk项目的时候,发现QT udpsocket绑定端口的时候不稳定,有时候可以,有时候又失败。尝试在绑定前解绑添加延时后,就稳定了,分享一下给大家一个参考。
m_udpSocket->abort();
QTest::qSleep (200); // delay 200ms
m_udpSocket->close ();
QTest::qSleep (200); //delay 200ms
qint16 port =8686; // = ui->lineEdit_LocalPort->text ().toInt ();
if(m_udpSocket->bind(QHostAddress::AnyIPv4, port)) //, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint))
{
}
标签:200,QT,Bind,绑定,delay,QUdpSocket,UDPsocket,port,udpSocket 来源: https://www.cnblogs.com/managechina/p/16698129.html