sockaddr_in6#

Dual-mode IPv6 shortcut: with two or more arguments it behaves like pack_sockaddr_in6; with a single argument it behaves like unpack_sockaddr_in6.

Synopsis#

my $sin6                          = sockaddr_in6($port, $addr);
my $sin6                          = sockaddr_in6($port, $addr, $scope, $flow);
my ($port, $addr, $scope, $flow)  = sockaddr_in6($sockaddr);

What you get back#

The same values as the underlying pack_sockaddr_in6 or unpack_sockaddr_in6, depending on argument count.

Examples#

my $sin6 = sockaddr_in6(443, inet_pton(AF_INET6, "::1"));
my ($port, $addr) = sockaddr_in6(getpeername($sock));

Edge cases#

  • The dispatch is on argument count — a single-element list still takes the unpack branch.

  • Prefer the explicit pack/unpack forms in new code.

Differences from upstream#

Fully compatible with upstream Socket.

See also#

  • pack_sockaddr_in6, unpack_sockaddr_in6 — the explicit forms.

  • sockaddr_in — IPv4 counterpart.