summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-03 21:46:52 +0000
committerrubidium <rubidium@openttd.org>2009-04-03 21:46:52 +0000
commit7cf4639255c7374750887ebfa4dd66bab37da1e7 (patch)
tree2698f8dccbccf94ceba0aa7622a40c7fc4c571f5 /src/network/core
parentccd2468eb2119bdc915f9a0a559374a299a7ca7f (diff)
downloadopenttd-7cf4639255c7374750887ebfa4dd66bab37da1e7.tar.xz
(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
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/address.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp
index aa18418f9..316a8b98a 100644
--- a/src/network/core/address.cpp
+++ b/src/network/core/address.cpp
@@ -172,12 +172,15 @@ static SOCKET ListenLoopProc(addrinfo *runp)
if (!SetNoDelay(sock)) DEBUG(net, 1, "Setting TCP_NODELAY failed");
- int reuse = 1;
+ int on = 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 (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)) == -1) {
+ DEBUG(net, 1, "Could not set reusable sockets: %s", strerror(errno));
+ }
+
+ 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) {