From 6a2dba9e8c1a896ba5a14b1205a3784c057c86fd Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 10 Nov 2020 23:08:54 +0300 Subject: [PATCH] Disable IPV6_V6ONLY on IPv6 server sockets on Windows. --- tdutils/td/utils/port/ServerSocketFd.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tdutils/td/utils/port/ServerSocketFd.cpp b/tdutils/td/utils/port/ServerSocketFd.cpp index 9cc685f97ebf..c294a04a4c9b 100644 --- a/tdutils/td/utils/port/ServerSocketFd.cpp +++ b/tdutils/td/utils/port/ServerSocketFd.cpp @@ -337,7 +337,11 @@ Result ServerSocketFd::open(int32 port, CSlice addr) { setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast(&flags), sizeof(flags)); #endif #elif TD_PORT_WINDOWS - BOOL flags = TRUE; + BOOL flags = FALSE; + if (address.is_ipv6()) { + setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast(&flags), sizeof(flags)); + } + flags = TRUE; #endif setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&flags), sizeof(flags)); setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, reinterpret_cast(&flags), sizeof(flags));