I use getaddrinfo(3)
to get list ip address from a domain which support both ipv4 and ipv6, but the local system support ipv4 only or both ipv4 & ipv6, As I expect, if system support both ipv4 & ipv6 getaddrinfo(3)
will query both ipv4 & ipv6 and if system support ipv4 only, getaddrinfo(3)
will query only ipv4.
I try to set ai_flags
to AI_ADDRCONFIG
but it still query both ipv4 & ipv6 while system support ipv4 only. How should I do
Here is my code:
struct addrinfo hint, *res = NULL, *p = NULL;
int err;
ACE_OS::memset(&hint, 0, sizeof hint);
hint.ai_family = AF_UNSPEC;
hint.ai_socktype = SOCK_STREAM;
hint.ai_flags = AI_ADDRCONFIG;
err = ACE_OS::getaddrinfo(hostname.c_str() ,"http", &hint, &res);