Type Method
from(storage:length:)
Wraps a kernel-supplied sockaddr_storage as a SocketAddress.
static func from(storage: sockaddr_storage, length: socklen_t) -> SocketAddress?
Parameters
-
storage
-
A sockaddr_storage already populated by the kernel.
-
length
-
The socklen_t the kernel reported via getsockname(2) / getpeername(2). Stored as-is; not validated against ss_family.
Discussion
Used by localAddress, localAddress, and remoteAddress to convert the result of getsockname(2) / getpeername(2) into the value type the rest of the API speaks. Returns nil for any address family other than AF_INET or AF_INET6 — the only families this package supports.
Exposed as a static factory rather than a failable initializer so the struct’s other initializers (ipv4(_:port:), ipv6(_:port:), anyIPv4(port:)) keep using the synthesised memberwise constructor.