unpack_sockaddr_un#

Extract the filesystem path from a packed sockaddr_un.

תקציר#

my ($path) = unpack_sockaddr_un($sockaddr);

מה מוחזר#

The sun_path field as a string, trimmed at the first NUL byte, or undef if the input is too short to be a sockaddr_un.

דוגמאות#

my ($path) = unpack_sockaddr_un(getsockname($sock));
print "listening on $path\n";

מקרי קצה#

  • Abstract Linux-namespace sockets have a leading NUL; the result is truncated at that first NUL, so callers that need the full abstract name must unpack the raw bytes themselves.

  • Input shorter than 3 bytes yields undef.

הבדלים מן ה-upstream#

Fully compatible with upstream Socket.

ראו גם#

  • pack_sockaddr_un - reverse direction.