aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Marvin Sielenkemper <sielenk@gmx.de>2016-09-17 08:22:12 +0200
committerGravatar Marvin Sielenkemper <sielenk@gmx.de>2016-09-17 08:28:19 +0200
commit10baddb6ee0fcd645ef0da096ef1dd5b6d4e09a4 (patch)
tree3905271c8b221409d303288b09bfb7e2e9847884
parent13a90684dc583427ad1d59a10d8bb00928fb6687 (diff)
Explicitly cleares IPV6_V6ONLY to ensure IPv4 availability
-rw-r--r--src/c/http.c9
1 files changed, 8 insertions, 1 deletions
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 <unistd.h>
#include <signal.h>
#include <stdarg.h>
+#include <error.h>
+#include <errno.h>
#include <pthread.h>
@@ -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