mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 21:02:17 +02:00
Reset NodeList upon local nework change; abort current socket when rebinding
Also ensure QUdpSocket is owned by LimitedNodeList.
This commit is contained in:
parent
aa65361b37
commit
d780964cb4
2 changed files with 4 additions and 2 deletions
|
@ -1239,6 +1239,7 @@ void LimitedNodeList::setLocalSocket(const HifiSockAddr& sockAddr) {
|
|||
} else {
|
||||
qCInfo(networking) << "Local socket has changed from" << _localSockAddr << "to" << sockAddr;
|
||||
if (_hasTCPCheckedLocalSocket) { // Force a port change for NAT:
|
||||
reset();
|
||||
_nodeSocket.rebind(0);
|
||||
_localSockAddr.setPort(_nodeSocket.localPort());
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ using namespace udt;
|
|||
|
||||
Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
|
||||
QObject(parent),
|
||||
_udpSocket(parent),
|
||||
_readyReadBackupTimer(new QTimer(this)),
|
||||
_shouldChangeSocketOptions(shouldChangeSocketOptions)
|
||||
{
|
||||
|
@ -50,6 +51,7 @@ Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
|
|||
}
|
||||
|
||||
void Socket::bind(const QHostAddress& address, quint16 port) {
|
||||
|
||||
_udpSocket.bind(address, port);
|
||||
|
||||
if (_shouldChangeSocketOptions) {
|
||||
|
@ -72,8 +74,7 @@ void Socket::rebind() {
|
|||
}
|
||||
|
||||
void Socket::rebind(quint16 localPort) {
|
||||
_udpSocket.close();
|
||||
_udpSocket.waitForDisconnected();
|
||||
_udpSocket.abort();
|
||||
bind(QHostAddress::AnyIPv4, localPort);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue