{
struct addrinfo hints = {0,};
struct addrinfo *ppres;
- const char hostname[] = "0.0.0.0";
+ const char hostname1[] = "0.0.0.0";
+ const char hostname2[] = "127.0.0.1";
+ const char hostname3[] = "::";
hints.ai_socktype = SOCK_STREAM;
- hints.ai_family = AF_INET;
+ hints.ai_family = AF_UNSPEC;
hints.ai_flags =
AI_NUMERICHOST|AI_PASSIVE|AI_ADDRCONFIG;
- return getaddrinfo(hostname, NULL, &hints, &ppres) != 0 ? 1 : 0;
+ /* Test for broken flag combination on AIX. */
+ if (getaddrinfo(hostname1, NULL, &hints, &ppres) == EAI_BADFLAGS) {
+ /* This fails on an IPv6-only box, but not with
+ the EAI_BADFLAGS error. */
+ return 1;
+ }
+ if (getaddrinfo(hostname2, NULL, &hints, &ppres) == 0) {
+ /* IPv4 lookup works - good enough. */
+ return 0;
+ }
+ /* Uh-oh, no IPv4. Are we IPv6-only ? */
+ return getaddrinfo(hostname3, NULL, &hints, &ppres) != 0 ? 1 : 0;
}],
libreplace_cv_HAVE_GETADDRINFO=yes,
libreplace_cv_HAVE_GETADDRINFO=no)