diff options
-rw-r--r-- | src/socket.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/socket.c b/src/socket.c index d4dedd1..3375e5b 100644 --- a/src/socket.c +++ b/src/socket.c @@ -463,6 +463,7 @@ int socket_create(const char* addr, uint16_t port) { int sfd = -1; int yes = 1; + int no = 0; struct addrinfo hints; struct addrinfo *result, *rp; char portstr[8]; @@ -514,7 +515,7 @@ int socket_create(const char* addr, uint16_t port) #if defined(AF_INET6) && defined(IPV6_V6ONLY) if (rp->ai_family == AF_INET6) { - if (setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&yes, sizeof(int)) == -1) { + if (setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (addr) ? (void*)&yes : (void*)&no, sizeof(int)) == -1) { perror("setsockopt() IPV6_V6ONLY"); } } |