Use IPv4 and v6 only when suitable interfaces are configured

Only on systems supporting AI_ADDRCONFIG.
This commit is contained in:
Markus Armbruster 2009-02-11 21:09:18 +01:00
parent 00b5cb2b8a
commit 7cce3124bf
2 changed files with 12 additions and 1 deletions

View file

@ -52,6 +52,11 @@
#endif
#include "misc.h"
/* Portability cruft, should become unnecessary eventually */
#ifndef AI_ADDRCONFIG
#define AI_ADDRCONFIG 0
#endif
#ifdef HAVE_GETADDRINFO
/*
* Inspired by example code from W. Richard Stevens: UNIX Network
@ -65,6 +70,7 @@ tcp_connect(char *host, char *serv)
struct addrinfo hints, *res, *ressave;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_ADDRCONFIG;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;