From 4269ec8c2a2e92c6a90eedd85c058674ef29fe6e Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Wed, 7 Jun 2023 18:38:13 +0200 Subject: [PATCH] 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 --- core/backends/lan/lanlinkprovider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index 724c54642..a80ffee76 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -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