From 7192ad301f1726c7de64f62e9aa5d2afc478ddf3 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 4 May 2016 16:22:57 -0700 Subject: [PATCH 1/3] add debug for socket errors and state changes --- libraries/networking/src/udt/Socket.cpp | 15 +++++++++++++++ libraries/networking/src/udt/Socket.h | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index cf66847b6c..f51c3762ea 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -36,6 +36,11 @@ Socket::Socket(QObject* parent) : // start our timer for the synchronization time interval _synTimer->start(_synInterval); + + // make sure we hear about errors and state chagnes from the underlying socket + connect(&_udpSocket, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(handleSocketError(QAbstractSocket::SocketError))); + connect(&_udpSocket, &QAbstractSocket::stateChanged, this, &Socket::handleStateChanged); } void Socket::bind(const QHostAddress& address, quint16 port) { @@ -406,3 +411,13 @@ std::vector Socket::getConnectionSockAddrs() { } return addr; } + +void Socket::handleSocketError(QAbstractSocket::SocketError socketError) { + qWarning() << "udt::Socket error -" << socketError; +} + +void Socket::handleStateChanged(QAbstractSocket::SocketState socketState) { + if (socketState != QAbstractSocket::BoundState) { + qWarning() << "udt::Socket state changed - state is now" << socketState; + } +} diff --git a/libraries/networking/src/udt/Socket.h b/libraries/networking/src/udt/Socket.h index 35a32a034f..6b8ccf1fa8 100644 --- a/libraries/networking/src/udt/Socket.h +++ b/libraries/networking/src/udt/Socket.h @@ -86,7 +86,10 @@ public slots: private slots: void readPendingDatagrams(); void rateControlSync(); - + + void handleSocketError(QAbstractSocket::SocketError socketError); + void handleStateChanged(QAbstractSocket::SocketState socketState); + private: void setSystemBufferSizes(); Connection& findOrCreateConnection(const HifiSockAddr& sockAddr); From effa2fc23551748eb19a4146a2dac0e04ced4f27 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 4 May 2016 16:28:26 -0700 Subject: [PATCH 2/3] typo fix for comment --- libraries/networking/src/udt/Socket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index f51c3762ea..4591f0d6b2 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -37,7 +37,7 @@ Socket::Socket(QObject* parent) : // start our timer for the synchronization time interval _synTimer->start(_synInterval); - // make sure we hear about errors and state chagnes from the underlying socket + // make sure we hear about errors and state changes from the underlying socket connect(&_udpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(handleSocketError(QAbstractSocket::SocketError))); connect(&_udpSocket, &QAbstractSocket::stateChanged, this, &Socket::handleStateChanged); From 8a3336ae95004e1225b4a2a7fb5a27e974ec84b3 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 4 May 2016 16:31:12 -0700 Subject: [PATCH 3/3] use the networking logging category --- libraries/networking/src/udt/Socket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 4591f0d6b2..b3ddc24914 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -413,11 +413,11 @@ std::vector Socket::getConnectionSockAddrs() { } void Socket::handleSocketError(QAbstractSocket::SocketError socketError) { - qWarning() << "udt::Socket error -" << socketError; + qCWarning(networking) << "udt::Socket error -" << socketError; } void Socket::handleStateChanged(QAbstractSocket::SocketState socketState) { if (socketState != QAbstractSocket::BoundState) { - qWarning() << "udt::Socket state changed - state is now" << socketState; + qCWarning(networking) << "udt::Socket state changed - state is now" << socketState; } }