inet_ntop#
Turn a packed IPv4 or IPv6 address back into its printable string form, selected by the first argument.
תקציר#
my $s = inet_ntop(AF_INET, $packed4);
my $s = inet_ntop(AF_INET6, $packed6);
מה מוחזר#
A dotted-quad string for AF_INET, a canonical colon-hex string (with :: compression) for AF_INET6, or undef if the input is too short or the family is unsupported.
דוגמאות#
print inet_ntop(AF_INET6, IN6ADDR_LOOPBACK); # ::1
my ($port, $addr, $scope, $flow) = unpack_sockaddr_in6($peer);
printf "[%s]:%d\n", inet_ntop(AF_INET6, $addr), $port;
מקרי קצה#
Input shorter than the family’s address length returns
undef.Any family other than
AF_INETorAF_INET6returnsundef.
הבדלים מן ה-upstream#
Fully compatible with upstream Socket.
ראו גם#
inet_pton- reverse direction, string to packed bytes.inet_ntoa- IPv4-only shortcut with no family argument.