Subject: | inet_pton does not work with hostnames (despite documentaton otherwise) |
Socket.pm in my debian perl 5.14 installation says:
inet_pton ADDRESS_FAMILY, HOSTNAME
Takes an address family, either AF_INET or AF_INET6, and a string
giving the name of a host, and translates that to an opaque string
(if programming in C, struct in_addr or struct in6_addr depending
on the address family passed in). The host string may be a string
hostname, such as 'www.perl.org', or an IP address. If using an IP
address, the type of IP address must be consistent with the address
family passed into the function.
However, using a hostname does not work (in contrast to inet_aton, where
it does work):
0 dkg@pip:~$ perl -MSocket -e 'printf("xx: %s\n", unpack("H*",
Socket::inet_aton("www.perl.org")));'
xx: cfab0733
0 dkg@pip:~$ perl -MSocket -e 'printf("xx: %s\n", unpack("H*",
Socket::inet_pton(AF_INET, "www.perl.org")));'
xx:
0 dkg@pip:~$
given that the underlying libc inet_pton() doesn't accept hostnames
(only ascii represenations ofIP addresses), perhaps it would be better
to just remove the claim from perl's documentation.