Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Socket

Native Rust implementation built into the interpreter. Runtime: P5. See original documentation for the full Perl reference.

Functions

getaddrinfo

Each result is a hashref: {family, socktype, protocol, addr, canonname}. Mirrors Socket.xs: wraps libc::getaddrinfo.

getnameinfo

Mirrors Socket.xs: wraps libc::getnameinfo.

import

no-op in p5 runtime; Exporter mechanism handles symbol copying.

in6addr_any

in6addr_loopback

inaddr_any

inaddr_broadcast

inaddr_loopback

inaddr_none

inet_aton

resolve to packed 4-byte IPv4 address or undef.

Mirrors Socket.xs: inet_aton tries inet_aton(3) which handles dotted-quad and hostnames. For now: dotted-quad + “localhost” fast path; hostname → DNS via libc::getaddrinfo (AF_INET).

inet_ntoa

convert 4-byte packed address to dotted-quad string.

Mirrors Socket.xs: calls inet_ntoa(3).

inet_ntop

AF-aware packed address to string.

Mirrors Socket.xs: calls inet_ntop(af, src, dst, size).

inet_pton

AF-aware address parsing.

Mirrors Socket.xs: calls inet_pton(af, src, dst).

pack_sockaddr_in

Mirrors Socket.xs: constructs struct sockaddr_in with sin_family=AF_INET, sin_port in network byte order, sin_addr from 4-byte packed input.

pack_sockaddr_in6

Mirrors Socket.xs: struct sockaddr_in6 layout.

pack_sockaddr_un

Mirrors Socket.xs: struct sockaddr_un, sun_path up to 107 bytes.

sockaddr_family

Mirrors Socket.xs: reads first two bytes as sa_family_t (native byte order).

sockaddr_in

sockaddr_in($sockaddr) (1 arg) = unpack_sockaddr_in

sockaddr_in6

sockaddr_in6($sockaddr) (1 arg) = unpack_sockaddr_in6

unpack_sockaddr_in

Mirrors Socket.xs: extracts sin_port (network→host) and sin_addr (4 bytes).

unpack_sockaddr_in6

unpack_sockaddr_un