From 25ae2ff0b8102d048d89669d82820787a1b2cb95 Mon Sep 17 00:00:00 2001 From: Alexander Sagen Date: Wed, 14 Aug 2024 12:59:43 +0200 Subject: [PATCH] cpp-httplib: Enable IPV6_V6ONLY flag to increase reliability of IPv4 service, as there are separate sockets for IPv4 and IPv6 --- ext/cpp-httplib/httplib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/cpp-httplib/httplib.h b/ext/cpp-httplib/httplib.h index dfdd260ab..bcaf4557c 100644 --- a/ext/cpp-httplib/httplib.h +++ b/ext/cpp-httplib/httplib.h @@ -3163,13 +3163,13 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port, if (socket_options) { socket_options(sock); } if (rp->ai_family == AF_INET6) { - auto no = 0; + auto yes = 1; #ifdef _WIN32 setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, - reinterpret_cast(&no), sizeof(no)); + reinterpret_cast(&yes), sizeof(yes)); #else setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, - reinterpret_cast(&no), sizeof(no)); + reinterpret_cast(&yes), sizeof(yes)); #endif }