diff options
author | Pierre Ossman <ossman@cendio.se> | 2015-04-23 11:23:16 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2015-04-23 11:23:16 +0200 |
commit | b6536e250a7ce5cd3a4d7415f3dbc79e18b71e53 (patch) | |
tree | 2aa04d8235ed55d136955d39d55ed173ac6dab00 /common | |
parent | 1c7a30409ddb97dde9d3c13f0486b55d43960e37 (diff) | |
download | tigervnc-b6536e250a7ce5cd3a4d7415f3dbc79e18b71e53.tar.gz tigervnc-b6536e250a7ce5cd3a4d7415f3dbc79e18b71e53.zip |
Repair SO_REUSEADDR
SO_REUSEADDR needs to be set before we call bind() for it to have
any effect. It got shuffled around in e4d9726.
Diffstat (limited to 'common')
-rw-r--r-- | common/network/TcpSocket.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx index 3b656cd7..99895ad8 100644 --- a/common/network/TcpSocket.cxx +++ b/common/network/TcpSocket.cxx @@ -440,11 +440,6 @@ TcpListener::TcpListener(const struct sockaddr *listenaddr, } #endif /* defined(IPV6_V6ONLY) */ - if (bind(sock, &sa.u.sa, listenaddrlen) == -1) { - closesocket(sock); - throw SocketException("failed to bind socket", errorNumber); - } - #ifndef WIN32 // - By default, close the socket on exec() fcntl(sock, F_SETFD, FD_CLOEXEC); @@ -457,6 +452,11 @@ TcpListener::TcpListener(const struct sockaddr *listenaddr, } #endif + if (bind(sock, &sa.u.sa, listenaddrlen) == -1) { + closesocket(sock); + throw SocketException("failed to bind socket", errorNumber); + } + // - Set it to be a listening socket if (listen(sock, 5) < 0) { int e = errorNumber; |