Attempt to make a temporary fix for Vista/Win7
authorJuho Vähä-Herttua <juhovh@iki.fi>
Tue, 15 May 2012 19:39:00 +0000 (22:39 +0300)
committerJuho Vähä-Herttua <juhovh@iki.fi>
Wed, 16 May 2012 21:57:07 +0000 (00:57 +0300)
src/lib/netutils.c

index 8226e4f32d8c926ea3b2e746babda0d0f56f1da9..8c7c5f74914b786f77432eef750e8133dce22c81 100644 (file)
@@ -71,12 +71,20 @@ netutils_init_socket(unsigned short *port, int use_ipv6, int use_udp)
        memset(&saddr, 0, sizeof(saddr));
        if (use_ipv6) {
                struct sockaddr_in6 *sin6ptr = (struct sockaddr_in6 *)&saddr;
+               int v6only = 0;
 
                /* Initialize sockaddr for bind */
                sin6ptr->sin6_family = family;
                sin6ptr->sin6_addr = in6addr_any;
                sin6ptr->sin6_port = htons(*port);
 
+               /* Make sure we also listen to IPv4 addresses */
+               ret = setsockopt(server_fd, IPPROTO_IPV6, IPV6_V6ONLY,
+                                (char *) &v6only, sizeof(v6only));
+               if (ret == -1) {
+                       goto cleanup;
+               }
+
                socklen = sizeof(*sin6ptr);
                ret = bind(server_fd, (struct sockaddr *)sin6ptr, socklen);
                if (ret == -1) {