```{index} single: pack_sockaddr_un; Socket function ``` ```{index} single: Socket::pack_sockaddr_un; Perl function ``` # pack_sockaddr_un Build a packed `sockaddr_un` from a filesystem path, for use with Unix-domain sockets. ## Synopsis ```perl my $sun = pack_sockaddr_un($path); ``` ## What you get back A fixed-size byte string matching the platform's `struct sockaddr_un`, ready for `bind` or `connect` against an `AF_UNIX` / `AF_LOCAL` socket. ## Examples ```perl socket(my $sock, AF_UNIX, SOCK_STREAM, 0) or die $!; connect($sock, pack_sockaddr_un("/tmp/app.sock")) or die $!; ``` ```perl ## Abstract Linux namespace: first byte is NUL. my $sun = pack_sockaddr_un("\0app.mysvc"); ``` ## Edge cases - Paths longer than 107 bytes are truncated to fit `sun_path`. - No explicit trailing NUL is appended by the caller; the struct is zero-initialised and the path is copied in. ## Differences from upstream Fully compatible with upstream Socket. ## See also - `unpack_sockaddr_un` — reverse direction. - `sockaddr_family` — read the family byte from an unknown sockaddr.