sockaddr_in#
Dual-mode shortcut: with two arguments it behaves like pack_sockaddr_in; with one argument it behaves like unpack_sockaddr_in.
Σύνοψη#
my $sin = sockaddr_in($port, $packed_ipv4);
my ($port, $addr) = sockaddr_in($sockaddr);
Τι επιστρέφεται#
The same values as the underlying pack_sockaddr_in or unpack_sockaddr_in, depending on argument count.
Παραδείγματα#
## Packing
connect($sock, sockaddr_in(80, inet_aton("127.0.0.1"))) or die $!;
## Unpacking
my ($port, $ip) = sockaddr_in(getpeername($sock));
Οριακές περιπτώσεις#
The dispatch is on argument count, not argument type. Calling with a single two-element list-in-scalar oddity will still take the unpack branch.
Prefer the explicit
pack_sockaddr_in/unpack_sockaddr_inin new code; this name exists for compatibility with older Perl idioms.
Διαφορές από το upstream#
Fully compatible with upstream Socket.
Δείτε επίσης#
pack_sockaddr_in,unpack_sockaddr_in- the explicit forms.sockaddr_in6- IPv6 counterpart with the same dual behaviour.