summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8f7c9a2)
But we prefer AF_INET6 over others when picking a socket. Problem
is that some systems has IPV6 support, but we can't create sockets
for them, so we pick AF_UNSPEC first.
if (!strcmp("@", host))
{
hints.ai_flags = AI_PASSIVE;
if (!strcmp("@", host))
{
hints.ai_flags = AI_PASSIVE;
- hints.ai_family = AF_INET6;
+ hints.ai_family = AF_UNSPEC;
error = getaddrinfo(0, port, &hints, &res);
*ipv6_only = 0;
}
error = getaddrinfo(0, port, &hints, &res);
*ipv6_only = 0;
}
int s = -1;
for (ai = sp->ai; ai; ai = ai->ai_next)
{
int s = -1;
for (ai = sp->ai; ai; ai = ai->ai_next)
{
- s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (s != -1)
- break;
+ if (ai->ai_family == AF_INET6)
+ {
+ s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ if (s != -1)
+ break;
+ }
+ }
+ if (s == -1)
+ {
+ for (ai = sp->ai; ai; ai = ai->ai_next)
+ {
+ s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ if (s != -1)
+ break;
+ }
}
if (s == -1)
return 0;
assert(ai);
h->iofile = s;
}
if (s == -1)
return 0;
assert(ai);
h->iofile = s;
+ if (ai->ai_family == AF_INET6 && ipv6_only >= 0 &&
setsockopt(h->iofile,
IPPROTO_IPV6,
IPV6_V6ONLY, &ipv6_only, sizeof(ipv6_only)))
setsockopt(h->iofile,
IPPROTO_IPV6,
IPV6_V6ONLY, &ipv6_only, sizeof(ipv6_only)))