Add error logging to LanLinkProvider when binding the listener socket
This commit is contained in:
parent
e111e1ad51
commit
637285378d
1 changed files with 8 additions and 1 deletions
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <QHostInfo>
|
||||
#include <QTcpServer>
|
||||
#include <QMetaEnum>
|
||||
#include <QNetworkProxy>
|
||||
#include <QUdpSocket>
|
||||
#include <QNetworkSession>
|
||||
|
@ -86,9 +87,15 @@ void LanLinkProvider::onStart()
|
|||
const QHostAddress bindAddress = m_testMode? QHostAddress::LocalHost : QHostAddress::Any;
|
||||
|
||||
bool success = m_udpSocket.bind(bindAddress, UDP_PORT, QUdpSocket::ShareAddress);
|
||||
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
|
||||
QString errorMessage = QLatin1String("Failed to bind UDP socket with error ");
|
||||
errorMessage = errorMessage + QMetaEnum::fromType<QAbstractSocket::SocketError>().valueToKey(sockErr);
|
||||
qCritical(errorMessage.toLocal8Bit().data());
|
||||
}
|
||||
Q_ASSERT(success);
|
||||
|
||||
|
||||
m_tcpPort = MIN_TCP_PORT;
|
||||
while (!m_server->listen(bindAddress, m_tcpPort)) {
|
||||
m_tcpPort++;
|
||||
|
|
Loading…
Reference in a new issue