mirror of https://github.com/OpenTTD/OpenTTD
(svn r15940) -Codechange: move setting reuse address to the binding process.
parent
2dafb9dd57
commit
1463b00b48
|
@ -163,6 +163,14 @@ static SOCKET ListenLoopProc(addrinfo *runp)
|
||||||
|
|
||||||
if (!SetNoDelay(sock)) DEBUG(net, 1, "Setting TCP_NODELAY failed");
|
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) {
|
if (bind(sock, runp->ai_addr, runp->ai_addrlen) != 0) {
|
||||||
DEBUG(net, 1, "Could not bind: %s", strerror(errno));
|
DEBUG(net, 1, "Could not bind: %s", strerror(errno));
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
|
|
|
@ -562,13 +562,6 @@ static bool NetworkListen()
|
||||||
return false;
|
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;
|
_listensocket = ls;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue