Set ReuseAddressHint in UDP socket
Tell Qt to bind even if something else listening to the same port. On Unix, this is implied by ShareAddress, but not on Windows [1]. [1] https://code.qt.io/cgit/qt/qtbase.git/tree/src/network/socket/qabstractsocket.cpp?h=5.9#n1565
This commit is contained in:
parent
dd187274f7
commit
4269ec8c2a
1 changed files with 1 additions and 1 deletions
|
@ -80,7 +80,7 @@ void LanLinkProvider::onStart()
|
|||
{
|
||||
const QHostAddress bindAddress = m_testMode ? QHostAddress::LocalHost : QHostAddress::Any;
|
||||
|
||||
bool success = m_udpSocket.bind(bindAddress, m_udpListenPort, QUdpSocket::ShareAddress);
|
||||
bool success = m_udpSocket.bind(bindAddress, m_udpListenPort, QAbstractSocket::ShareAddress | QAbstractSocket::ReuseAddressHint);
|
||||
if (!success) {
|
||||
QAbstractSocket::SocketError sockErr = m_udpSocket.error();
|
||||
// Refer to https://doc.qt.io/qt-5/qabstractsocket.html#SocketError-enum to decode socket error number
|
||||
|
|
Loading…
Reference in a new issue