GetAddrInfo cannot resolve ipv6.google.com (but nslookup can)

喜夏-厌秋 提交于 2019-12-06 16:09:51

Try passing AF_INET6 in pHints parameter to work with IPV6 addresses. This seems to be working for me:

struct addrinfo *result = NULL;
struct addrinfo hints;

ZeroMemory( &hints, sizeof(hints) );
hints.ai_family = AF_INET6;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;

dwRetval = getaddrinfo("ipv6.google.com", NULL, &hints, &result);
// check your dwRetval here ...

I had similar issues, wasn't a problem with the code, but the operating system. The following command meant windows resolved the IPv6 addresses correctly instead of giving a WSANO_DATA error:

Netsh interface teredo set state enterpriseclient

Source:

http://netscantools.blogspot.co.uk/2011/06/ipv6-teredo-problems-and-solutions-on.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!