unpack_sockaddr_un#
Extract the filesystem path from a packed sockaddr_un.
Synopsis#
my ($path) = unpack_sockaddr_un($sockaddr);
What you get back#
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.
Examples#
my ($path) = unpack_sockaddr_un(getsockname($sock));
print "listening on $path\n";
Edge cases#
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.
Differences from upstream#
Fully compatible with upstream Socket.
See also#
pack_sockaddr_un— reverse direction.