Merge pull request from birarda/stuck-assignment

add warnings for socket error and unexpected state change
This commit is contained in:
Seth Alves 2016-05-05 08:58:51 -07:00
commit 24289b1e66
2 changed files with 19 additions and 1 deletions
libraries/networking/src/udt

View file

@ -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 changes 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<HifiSockAddr> Socket::getConnectionSockAddrs() {
}
return addr;
}
void Socket::handleSocketError(QAbstractSocket::SocketError socketError) {
qCWarning(networking) << "udt::Socket error -" << socketError;
}
void Socket::handleStateChanged(QAbstractSocket::SocketState socketState) {
if (socketState != QAbstractSocket::BoundState) {
qCWarning(networking) << "udt::Socket state changed - state is now" << socketState;
}
}

View file

@ -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);