static int
socketopen(int family, int type, const char *localpname,
const char *remotepname, const char *remotehostname, bool
*hard_error)
{
[snip]
memset(& lhints, '\0', sizeof (lhints));
/* if only the loopback interface is up and hints.ai_flags
has AI_ADDRCONFIG,
getaddrinfo() will return the addresses of the loopback
interface, but only
if hints.ai_family == AF_UNSPEC
*/
lhints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
lhints.ai_socktype = type;
lhints.ai_family = family;
// do return the loopback address in case the loopback interface is
the only one that
// is up (and hints.ai_family == AF_INET[46])
if ( (lhints.ai_family == AF_INET) || (lhints.ai_family == AF_INET6)
)
lhints.ai_flags = AI_PASSIVE;
lerror = getaddrinfo(NULL, localpname, & lhints, & lres);
...