diff options
author | rubidium <rubidium@openttd.org> | 2009-04-03 17:02:29 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-04-03 17:02:29 +0000 |
commit | 1463b00b48a67bdbd8ad0ebdd327d38f42466248 (patch) | |
tree | 5f160b2b98b6d146758e1b26055a2f42ad66a404 | |
parent | 2dafb9dd577e49bbbe9572f9529a4abfa2f9b9bc (diff) | |
download | openttd-1463b00b48a67bdbd8ad0ebdd327d38f42466248.tar.xz |
(svn r15940) -Codechange: move setting reuse address to the binding process.
-rw-r--r-- | src/network/core/address.cpp | 8 | ||||
-rw-r--r-- | src/network/network.cpp | 7 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp index 5a79a436e..0498c793f 100644 --- a/src/network/core/address.cpp +++ b/src/network/core/address.cpp @@ -163,6 +163,14 @@ static SOCKET ListenLoopProc(addrinfo *runp) if (!SetNoDelay(sock)) DEBUG(net, 1, "Setting TCP_NODELAY failed"); + int reuse = 1; + /* The (const char*) cast is needed for windows!! */ + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse)) == -1) { + DEBUG(net, 1, "Could not bind, setsockopt() failed:", strerror(errno)); + closesocket(sock); + return INVALID_SOCKET; + } + if (bind(sock, runp->ai_addr, runp->ai_addrlen) != 0) { DEBUG(net, 1, "Could not bind: %s", strerror(errno)); closesocket(sock); diff --git a/src/network/network.cpp b/src/network/network.cpp index d2f918748..09e4e7a40 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -562,13 +562,6 @@ static bool NetworkListen() return false; } - int reuse = 1; - /* The (const char*) cast is needed for windows!! */ - if (setsockopt(ls, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse)) == -1) { - ServerStartError("setsockopt() on listen socket failed"); - return false; - } - _listensocket = ls; return true; |