From 10baddb6ee0fcd645ef0da096ef1dd5b6d4e09a4 Mon Sep 17 00:00:00 2001 From: Marvin Sielenkemper Date: Sat, 17 Sep 2016 08:22:12 +0200 Subject: Explicitly cleares IPV6_V6ONLY to ensure IPv4 availability --- src/c/http.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/c') diff --git a/src/c/http.c b/src/c/http.c index 5752fc6f..b3ada18a 100644 --- a/src/c/http.c +++ b/src/c/http.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include @@ -328,7 +330,7 @@ int main(int argc, char *argv[]) { struct sockaddr_in6 my_addr; struct sockaddr_in6 their_addr; // connector's address information socklen_t sin_size; - int yes = 1, uw_port = 8080, nthreads = 1, i, *names, opt; + int yes = 1, no = 0, uw_port = 8080, nthreads = 1, i, *names, opt; int recv_timeout_sec = 5; signal(SIGINT, sigint); @@ -425,6 +427,11 @@ int main(int argc, char *argv[]) { return 1; } + if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(int)) < 0) { + fprintf(stderr, "Listener IPV6_V6ONLY option resetting failed\n"); + return 1; + } + my_addr.sin6_family = AF_INET6; // host byte order my_addr.sin6_port = htons(uw_port); // short, network byte order -- cgit v1.2.3