pack_sockaddr_un#

Build a packed sockaddr_un from a filesystem path, for use with Unix-domain sockets.

Σύνοψη#

my $sun = pack_sockaddr_un($path);

Τι επιστρέφεται#

A fixed-size byte string matching the platform’s struct sockaddr_un, ready for bind or connect against an AF_UNIX / AF_LOCAL socket.

Παραδείγματα#

socket(my $sock, AF_UNIX, SOCK_STREAM, 0) or die $!;
connect($sock, pack_sockaddr_un("/tmp/app.sock")) or die $!;
## Abstract Linux namespace: first byte is NUL.

my $sun = pack_sockaddr_un("\0app.mysvc");

Οριακές περιπτώσεις#

  • 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.

Διαφορές από το upstream#

Fully compatible with upstream Socket.

Δείτε επίσης#

  • unpack_sockaddr_un - reverse direction.

  • sockaddr_family - read the family byte from an unknown sockaddr.