2011-01-27 65 views
3

當試圖解析Facebook的數字IP地址作爲測試2620:0:1cfe:face:b00c::3:,如果我離開終止0關閉地址,inet_pton() barfs。如果我把它放在一切工作。這是IPv6中inet_pton的錯誤嗎?

運行Ubuntu 9.10:

rc = inet_pton(AF_INET6, "2620:0:1cfe:face:b00c::3:0", &ip); -> OK 
rc = inet_pton(AF_INET6, "2620:0:1cfe:face:b00c::3:", &ip); -> returns -2 

ping6 -n www.v6.facebook.com返回的IP地址W/O後0

回答

3

看來,平,這是偉大的智慧,像這樣的IP地址後加冒號:

PING maclawran.ca (173.230.128.18) 56(84) bytes of data. 
64 bytes from ns.maclawran.ca (173.230.128.18): icmp_seq=1 ttl=51 time=50.3 ms 

當然,如果你正在查驗的IPv6地址,它已經得到了很多冒號在它:

PING 2620:0:1cfe:face:b00c::3(2620:0:1cfe:face:b00c::3) 56 data bytes 
64 bytes from 2620:0:1cfe:face:b00c::3: icmp_seq=1 ttl=52 time=9.44 ms 
======================================^ << THANKS PING 
+2

無論如何,「2620:0:1cfe:face:b00c :: 3:」不是「2620:0:1cfe:face:b00c :: 3:0」的有效縮寫。 – Jumbogram 2011-01-28 00:51:36