Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winapi GetAddrInfo无法解析ipv6.google.com(但nslookup可以)_Winapi_Sockets_Dns_Ipv6 - Fatal编程技术网

Winapi GetAddrInfo无法解析ipv6.google.com(但nslookup可以)

Winapi GetAddrInfo无法解析ipv6.google.com(但nslookup可以),winapi,sockets,dns,ipv6,Winapi,Sockets,Dns,Ipv6,我可以尝试使用来解决: 返回的套接字错误代码为11001(不知道这样的主机) 注意:不推荐使用的旧功能不支持IPv6。它已被替换为 奇怪的是,我可以使用nslookup,它可以很好地找到地址: 问题 SendRequest(), len 33 HEADER: opcode = QUERY, id = 4, rcode = NOERROR header flags: query, want recursion questions = 1,

我可以尝试使用来解决:

返回的套接字错误代码为
11001
(不知道这样的主机)

注意:不推荐使用的旧功能不支持IPv6。它已被替换为

奇怪的是,我可以使用
nslookup
,它可以很好地找到地址:

问题

SendRequest(), len 33
    HEADER:
        opcode = QUERY, id = 4, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        ipv6.google.com, type = A, class = IN
SendRequest(), len 33
    HEADER:
        opcode = QUERY, id = 5, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        ipv6.google.com, type = AAAA, class = IN
权威答案

Got answer (106 bytes):
    HEADER:
        opcode = QUERY, id = 4, rcode = NOERROR
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 1,  authority records = 1,  additional = 0

    QUESTIONS:
        ipv6.google.com, type = A, class = IN
    ANSWERS:
    ->  ipv6.google.com
        type = CNAME, class = IN, dlen = 9
        canonical name = ipv6.l.google.com
        ttl = 21743 (6 hours 2 mins 23 secs)
    AUTHORITY RECORDS:
    ->  l.google.com
        type = SOA, class = IN, dlen = 38
        ttl = 30 (30 secs)
        primary name server = ns4.google.com
        responsible mail addr = dns-admin.google.com
        serial  = 1486713
        refresh = 900 (15 mins)
        retry   = 900 (15 mins)
        expire  = 1800 (30 mins)
        default TTL = 60 (1 min)
Got answer (82 bytes):
    HEADER:
        opcode = QUERY, id = 5, rcode = NOERROR
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 2,  authority records = 0,  additional = 0

    QUESTIONS:
        ipv6.google.com, type = AAAA, class = IN
    ANSWERS:
    ->  ipv6.google.com
        type = CNAME, class = IN, dlen = 9
        canonical name = ipv6.l.google.com
        ttl = 21743 (6 hours 2 mins 23 secs)
    ->  ipv6.l.google.com
        type = AAAA, class = IN, dlen = 16
        AAAA IPv6 address = 2607:f8b0:4009:801::1012
        ttl = 270 (4 mins 30 secs)

------------
Name:    ipv6.l.google.com
Address:  2607:f8b0:4009:801::1012
Aliases:  ipv6.google.com
非权威性问题

SendRequest(), len 33
    HEADER:
        opcode = QUERY, id = 4, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        ipv6.google.com, type = A, class = IN
SendRequest(), len 33
    HEADER:
        opcode = QUERY, id = 5, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        ipv6.google.com, type = AAAA, class = IN
非权威性回答

Got answer (106 bytes):
    HEADER:
        opcode = QUERY, id = 4, rcode = NOERROR
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 1,  authority records = 1,  additional = 0

    QUESTIONS:
        ipv6.google.com, type = A, class = IN
    ANSWERS:
    ->  ipv6.google.com
        type = CNAME, class = IN, dlen = 9
        canonical name = ipv6.l.google.com
        ttl = 21743 (6 hours 2 mins 23 secs)
    AUTHORITY RECORDS:
    ->  l.google.com
        type = SOA, class = IN, dlen = 38
        ttl = 30 (30 secs)
        primary name server = ns4.google.com
        responsible mail addr = dns-admin.google.com
        serial  = 1486713
        refresh = 900 (15 mins)
        retry   = 900 (15 mins)
        expire  = 1800 (30 mins)
        default TTL = 60 (1 min)
Got answer (82 bytes):
    HEADER:
        opcode = QUERY, id = 5, rcode = NOERROR
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 2,  authority records = 0,  additional = 0

    QUESTIONS:
        ipv6.google.com, type = AAAA, class = IN
    ANSWERS:
    ->  ipv6.google.com
        type = CNAME, class = IN, dlen = 9
        canonical name = ipv6.l.google.com
        ttl = 21743 (6 hours 2 mins 23 secs)
    ->  ipv6.l.google.com
        type = AAAA, class = IN, dlen = 16
        AAAA IPv6 address = 2607:f8b0:4009:801::1012
        ttl = 270 (4 mins 30 secs)

------------
Name:    ipv6.l.google.com
Address:  2607:f8b0:4009:801::1012
Aliases:  ipv6.google.com

当无法解析地址时,是什么导致
nslookup
能够解析地址?我可以用
GetAddrInfo
做些什么不同的事情,这样它就可以工作了?

尝试在
pHints
中传递
AF\u INET6
参数来处理IPV6地址。这似乎对我有用:

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 ...

我也有类似的问题,不是代码问题,而是操作系统问题。以下命令表示windows正确解析了IPv6地址,而不是给出WSANO_数据错误:

Netsh接口teredo设置状态enterpriseclient

资料来源:


允许我解析
ipv6.google.com
,但是
stackoverflow.com
无法解析。我仍然需要解决
nslookup
如何管理它的问题。我找到了
nslookup
如何完成它的任务。它运行
A
查询,然后分别执行
AAAA
查找。因此,我必须调用
getaddrinfo
两次,一次用于IPv6,另一次用于IPv4。请尝试将
hits.ai_family
设置为
AF_unsec
以允许
getaddrinfo()
同时查询IPv4和IPv6信息。@RemyLebeau将family设置为AF_unsec没有帮助。我想也许家庭应该有一点标志(
AF_INET6或AF_INET
);但它不是位标志。不,它不是位掩码。明确指出:“对于ai_系列,AF_unsec的值表示调用者将接受任何协议系列。此值可用于返回pNodeName参数所指向主机名的IPv4和IPv6地址。在Windows Server 2003和Windows XP上,仅当本地计算机上安装了IPv6时,才会返回IPv6地址。”