Commit 63728537 authored by Simon Redman's avatar Simon Redman

Add error logging to LanLinkProvider when binding the listener socket

parent e111e1ad
Pipeline #3994 failed with stage
in 5 minutes and 4 seconds
......@@ -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++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment