```{index} single: inet_ntop; Socket function ``` ```{index} single: Socket::inet_ntop; Perl function ``` # inet_ntop Turn a packed IPv4 or IPv6 address back into its printable string form, selected by the first argument. ## Synopsis ```perl my $s = inet_ntop(AF_INET, $packed4); my $s = inet_ntop(AF_INET6, $packed6); ``` ## What you get back 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. ## Examples ```perl print inet_ntop(AF_INET6, IN6ADDR_LOOPBACK); # ::1 ``` ```perl my ($port, $addr, $scope, $flow) = unpack_sockaddr_in6($peer); printf "[%s]:%d\n", inet_ntop(AF_INET6, $addr), $port; ``` ## Edge cases - Input shorter than the family's address length returns `undef`. - Any family other than `AF_INET` or `AF_INET6` returns `undef`. ## Differences from upstream Fully compatible with upstream Socket. ## See also - `inet_pton` — reverse direction, string to packed bytes. - `inet_ntoa` — IPv4-only shortcut with no family argument.