From c66d97726931aa8dde7d8a1ffa5b8e41234f4660 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 22 Jun 2018 20:54:23 +0200 Subject: [PATCH] Fix ipv6_server=true not accepting IPv4 connections on Windows (#7471) --- src/network/socket.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/network/socket.cpp b/src/network/socket.cpp index 053013606..94a9f4180 100644 --- a/src/network/socket.cpp +++ b/src/network/socket.cpp @@ -118,6 +118,15 @@ bool UDPSocket::init(bool ipv6, bool noExceptions) setTimeoutMs(0); + if (m_addr_family == AF_INET6) { + // Allow our socket to accept both IPv4 and IPv6 connections + // required on Windows: + // https://msdn.microsoft.com/en-us/library/windows/desktop/bb513665(v=vs.85).aspx + int value = 0; + setsockopt(m_handle, IPPROTO_IPV6, IPV6_V6ONLY, + reinterpret_cast(&value), sizeof(value)); + } + return true; } -- 2.25.1