You've already forked cpp-httplib
server: support dual-stack server socket (#450)
According to RFC 3493 the socket option IPV6_V6ONLY should be off by default, see https://tools.ietf.org/html/rfc3493#page-22 (chapter 5.3). However this does not seem to be the case on all systems. For instance on any Windows OS, the option is on by default. Therefore clear this option in order to allow an server socket which can support IPv6 and IPv4 at the same time.
This commit is contained in:
@ -1469,6 +1469,11 @@ socket_t create_socket(const char *host, int port, Fn fn,
|
||||
int yes = 1;
|
||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&yes),
|
||||
sizeof(yes));
|
||||
|
||||
int no = 0;
|
||||
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<char *>(&no),
|
||||
sizeof(no));
|
||||
|
||||
#ifdef SO_REUSEPORT
|
||||
setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast<char *>(&yes),
|
||||
sizeof(yes));
|
||||
|
Reference in New Issue
Block a user