The socket uses IPv6. I'm guessing you're using localhost and that Squeeze defines localhost as ::1. The dumb thing is that sockaddr doesn't tell you if what kind of address it's returning. The module, was written with only IPv4 in mind.
Here's how you can address this in a portable manner:
use Socket qw( sockaddr_family sockaddr_in sockaddr_in6 inet_ntop AF_I +NET ); my $sockaddr = getsockaddr($sock); # Or: $sock->sockname() my $fam = sockaddr_family($sockaddr); my $addr_n = $fam == AF_INET ? (sockaddr_in($sockaddr))[1] : (sockaddr_in6($sockaddr))[1]; my $addr_a = inet_ntop($fam, $addr_n); say $addr_a;
In reply to Re: IO::Socket::INET's sockaddr() returns 16 byte instead of 4, Socket::inet_ntoa() complains
by ikegami
in thread IO::Socket::INET's sockaddr() returns 16 byte instead of 4, Socket::inet_ntoa() complains
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |