-
- /* now we've got a socket - we need to bind it */
- if (bind(s, all_ai->ai_addr, all_ai->ai_addrlen) < 0) {
+
+#ifdef IPV6_V6ONLY
+ if (resp->ai_family == AF_INET6) {
+ setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
+ (char *)&one, sizeof one);
+ }
+#endif
+
+ /* Now we've got a socket - we need to bind it. */
+ if (bind(s, resp->ai_addr, resp->ai_addrlen) < 0) {