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.
Examples#
my ($path) = unpack_sockaddr_un(getsockname($sock));
print "listening on $path\n";
Edge cases#
An abstract Linux-namespace name (leading NUL) comes back whole, NULs included: its length is the structure’s length less the family field.
A structure shorter than
struct sockaddr_unis accepted, as the kernel returns fromaccept,recvfrom,getpeernameandgetsockname.undefcroaks “Undefined address for Socket::unpack_sockaddr_un”; a family other thanAF_UNIXcroaks “Bad address family”.
See also#
pack_sockaddr_un- reverse direction.