1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-22 14:09:10 +00:00

(svn r15944) -Codechange: disable IPv4 over IPv6 sockets as there is no default value and not all OSes actually support IPv4 over IPv6 so making it the same on all OSes eases debugging and such

This commit is contained in:
rubidium
2009-04-03 21:46:52 +00:00
parent ccd2468eb2
commit 7cf4639255

View File

@@ -172,12 +172,15 @@ 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; int on = 1;
/* The (const char*) cast is needed for windows!! */ /* The (const char*) cast is needed for windows!! */
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse)) == -1) { if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)) == -1) {
DEBUG(net, 1, "Could not bind, setsockopt() failed:", strerror(errno)); DEBUG(net, 1, "Could not set reusable sockets: %s", strerror(errno));
closesocket(sock); }
return INVALID_SOCKET;
if (runp->ai_family == AF_INET6 &&
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&on, sizeof(on)) == -1) {
DEBUG(net, 1, "Could not disable IPv4 over IPv6: %s", strerror(errno));
} }
if (bind(sock, runp->ai_addr, runp->ai_addrlen) != 0) { if (bind(sock, runp->ai_addr, runp->ai_addrlen) != 0) {