diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 9c6dd4af3..1c3ebb545 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -50,6 +50,13 @@ bool SslServer::hasDualStackSupport() { bool result = false; #ifdef Q_OS_UNIX int s = ::socket(AF_INET6, SOCK_STREAM, 0); + if (s != -1) { + const int ipv6only = 0; + if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast(&ipv6only), sizeof(ipv6only)) == 0) { + result = true; + } + ::close(s); + } #else WSADATA wsaData; WORD wVersionRequested = MAKEWORD(2, 2); @@ -59,17 +66,11 @@ bool SslServer::hasDualStackSupport() { } SOCKET s = ::WSASocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); -#endif - - if (s != -1) { // Equals INVALID_SOCKET + if (s != INVALID_SOCKET) { const int ipv6only = 0; if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast(&ipv6only), sizeof(ipv6only)) == 0) { result = true; } -#ifdef Q_OS_UNIX - ::close(s); - } -#else closesocket(s); } WSACleanup();