unpack_sockaddr_in6#
Split a packed sockaddr_in6 into port, 16-byte address, scope id, and flow-info.
Synopsis#
my ($port, $addr, $scope_id, $flowinfo) = unpack_sockaddr_in6($sockaddr);
What you get back#
A four-element list in list context; the address alone in scalar context.
Examples#
my ($port, $addr, $scope, $flow) = unpack_sockaddr_in6(getpeername($sock));
printf "[%s%%%d]:%d\n", inet_ntop(AF_INET6, $addr), $scope, $port;
Edge cases#
Scope id and flow-info are often 0 for non-link-local traffic.
Input that is not exactly a
sockaddr_in6croaks “Bad arg length”;undefcroaks “Undefined address”.A family other than
AF_INET6croaks “Bad address family”.
See also#
pack_sockaddr_in6- reverse direction.unpack_sockaddr_in- IPv4 counterpart.inet_ntop- turn the returned packed address into a string.