As far as i know the ai_family should be either set to AF_INET or AF_INET6. Anything else would undefined. Check the spec. AF_INET would return IPv4 and AF_INET6 would return IPV6 address...