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) {