abla/sys/linux/net

Generated from source.

Import with import "abla/sys/linux/net".

Source: abla/sys/linux/net/entry.ab

Re-exports abla/sys/linux/descriptor-result.

SocketPeerAddress (class)

class SocketPeerAddress(val address: string, val port: int, val family: int, val scopeId: int = 0)

A peer IP and port; family is 4 or 6, with an IPv6 scope when present.

Ipv4SocketAddress (class)

class Ipv4SocketAddress(val address: string, val port: int)

A numeric IPv4 address string and port. Construction stores both fields unchanged. Use isValid to check their form and range.

Ipv6SocketAddress (class)

class Ipv6SocketAddress(
    val address: string,
    val port: int,
    val scopeId: int
)

Holds a numeric IPv6 address, port, and interface scope identifier.

linuxTcpReceiveDescriptor (fun)

trusted fun linuxTcpReceiveDescriptor(descriptor: int, capacity: int, var result: SocketReceiveResult): void

Reads once from a descriptor, without waiting when it is nonblocking, into the reusable result. capacity is the most it takes: 1 to 1048576, and no more than 65536 are read at once (a bigger value is read as 65536); a value outside 1..1048576 sets status to -22 (EINVAL) and reads nothing. status holds the byte count (the received bytes are in text, copied into an exactly sized string, so a small message never pins a read-sized block), zero at EOF, or a negative errno (-11 when the descriptor would block). An interrupted read is retried. The descriptor stays open.

linuxTcpConnectStart (fun)

trusted fun linuxTcpConnectStart(address: string, port: int): int

Starts a nonblocking connection to address, which must be an IPv4 address in dotted-quad text ("127.0.0.1": a host name, an abbreviated or an IPv6 form is -22, never a guess; so is a port outside 1..65535), with TCP_NODELAY set. The connection is made or in progress (EINPROGRESS: wait for the descriptor to become writable, then linuxSocketPendingError says whether it succeeded). Returns the descriptor (SOCK_NONBLOCK | SOCK_CLOEXEC), or -errno; a failed connect closes it.

linuxSocketPendingError (fun)

trusted fun linuxSocketPendingError(descriptor: int): int

The pending error of a socket (SO_ERROR, which a read clears): zero when there is none, else a positive errno (ECONNREFUSED, ETIMEDOUT, ...); the errno of the failed query itself, also positive, when the descriptor is no socket.

SocketReadResult (class)

class SocketReadResult(
    val bytes: string,
    val status: string,
    val errorCode: int
)

Holds read bytes, the completion status, and the errno for a failed read.

SocketReadResult.hasData (method)

fun hasData(): bool

Returns true when the read produced data.

SocketReadResult.reachedEof (method)

fun reachedEof(): bool

Returns true when the stream reached EOF.

SocketReadResult.timedOut (method)

fun timedOut(): bool

Returns true when the read timed out.

SocketReadResult.failed (method)

fun failed(): bool

Returns true when the read ended in a socket error.

SocketReadResult.networkOutcome (extension fun)

fun SocketReadResult.networkOutcome(
    operation: string = "read"
): NetworkReadOutcome

Returns the portable read outcome, mapping errno 11 to would-block.

SocketWriteResult (class)

class SocketWriteResult(
    val written: int,
    val status: string,
    val errorCode: int
)

Holds the number of bytes written, completion status, and the errno for a failed write.

SocketWriteResult.succeeded (method)

fun succeeded(): bool

Returns true when the write completed with written status.

SocketWriteResult.timedOut (method)

fun timedOut(): bool

Returns true when the write timed out.

SocketWriteResult.failed (method)

fun failed(): bool

Returns true when the write ended in a socket error.

SocketWriteResult.networkOutcome (extension fun)

fun SocketWriteResult.networkOutcome(
    operation: string = "write"
): NetworkWriteOutcome

Returns the portable write outcome, mapping errno 11 to would-block.

SocketPollResult (class)

class SocketPollResult(
    val readable: bool,
    val writable: bool,
    val closed: bool,
    val timedOut: bool,
    val errorCode: int
)

Reports readiness, closure, timeout, and any poll error.

SocketPollResult.failed (method)

fun failed(): bool

Returns true when polling reported a nonzero errno.

SocketEvent (class)

class SocketEvent(
    val descriptor: int,
    val readable: bool,
    val writable: bool,
    val closed: bool,
    val error: bool
)

Reports readiness, closure, or an error event for one descriptor.

SocketEvents (class)

class SocketEvents(
    val events: array<SocketEvent>,
    val timedOut: bool,
    val errorCode: int
)

Holds ready events, the timeout flag, and any kernel polling error.

SocketEvents.failed (method)

fun failed(): bool

Returns true when the kernel reported a polling error.

UdpDatagram (class)

class UdpDatagram(
    val bytes: string,
    val source: Ipv4SocketAddress,
    val received: bool,
    val timedOut: bool,
    val truncated: bool,
    val errorCode: int
)

Holds a datagram and its IPv4 source, with separate flags for receipt, timeout, and truncation.

UdpDatagramIpv6 (class)

class UdpDatagramIpv6(
    val bytes: string,
    val source: Ipv6SocketAddress,
    val received: bool,
    val timedOut: bool,
    val truncated: bool,
    val errorCode: int
)

Holds a datagram and its IPv6 source, with separate flags for receipt, timeout, and truncation.

TcpListener (class)

resource class TcpListener(var descriptor: int)

Owns a listening descriptor and closes it on drop. A negative descriptor represents a failed or closed listener.

TcpListener.drop (method)

trusted fun drop(): void

Closes the owned listening descriptor and marks it closed.

TcpConnection (class)

resource class TcpConnection(var descriptor: int)

Owns a connected descriptor and closes it on drop. A negative descriptor represents a failed or closed connection.

TcpConnection.drop (method)

trusted fun drop(): void

Closes the owned TCP connection descriptor and marks it closed.

UdpSocket (class)

resource class UdpSocket(var descriptor: int)

Owns a UDP descriptor, with a negative descriptor representing a failed or closed socket.

UdpSocket.drop (method)

trusted fun drop(): void

Closes the owned UDP descriptor and marks it closed.

SocketPoller (class)

resource class SocketPoller(var descriptor: int)

An owned kernel poller for monitoring descriptor readiness. A negative descriptor represents a failed or closed poller.

SocketPoller.drop (method)

trusted fun drop(): void

Closes the owned polling descriptor and marks it closed.

linuxNetStoreU16 (fun)

trusted fun linuxNetStoreU16(
    var buffer: NativeByteBuffer,
    offset: int,
    value: int
): bool

Stores the low 16 bits of value little endian at offset in buffer. Returns false on a failed store, which may leave an earlier byte written.

linuxNetStoreU32 (fun)

trusted fun linuxNetStoreU32(
    var buffer: NativeByteBuffer,
    offset: int,
    value: int
): bool

Stores the low 32 bits of value little endian at offset in buffer. Returns false on a failed store and may have written a prefix.

linuxNetReadNativeU16 (fun)

trusted fun linuxNetReadNativeU16(buffer: NativeByteBuffer, offset: int): int

Returns two little-endian bytes as an unsigned word, treating unavailable bytes as zero.

linuxNetReadNativeU32 (fun)

trusted fun linuxNetReadNativeU32(buffer: NativeByteBuffer, offset: int): int

Reads four bytes little endian at offset in buffer. Missing or closed-buffer bytes read as zero.

ipv4SocketAddress (fun)

fun ipv4SocketAddress(address: string, port: int): Ipv4SocketAddress

Wraps address and port as an IPv4 endpoint. Use isValid to check them.

ipv4Any (fun)

fun ipv4Any(port: int): Ipv4SocketAddress

Returns an IPv4 bind address for all local interfaces on port.

ipv4Loopback (fun)

fun ipv4Loopback(port: int): Ipv4SocketAddress

Returns the IPv4 loopback endpoint on port.

ipv6SocketAddress (fun)

fun ipv6SocketAddress(
    address: string,
    port: int,
    scopeId: int = 0
): Ipv6SocketAddress

Wraps numeric IPv6 address, port, and scopeId. Use isValid to check the address and port.

ipv6Any (fun)

fun ipv6Any(port: int): Ipv6SocketAddress

Returns the IPv6 wildcard bind address on the given port.

ipv6Loopback (fun)

fun ipv6Loopback(port: int): Ipv6SocketAddress

Returns the IPv6 loopback address on the given port.

Ipv4SocketAddress.isValid (extension fun)

fun Ipv4SocketAddress.isValid(): bool

Returns true for a numeric IPv4 address and a port from 0 through 65535.

linuxIpv6Words (fun)

fun linuxIpv6Words(address: string): array<int>

Returns the eight words of a numeric IPv6 address, or an empty array if the spelling is invalid.

Ipv6SocketAddress.isValid (extension fun)

fun Ipv6SocketAddress.isValid(): bool

Returns true if the numeric IPv6 address, port, and scope fit the supported endpoint format.

linuxTcpCloseDescriptor (fun)

trusted fun linuxTcpCloseDescriptor(descriptor: int): bool

Closes the raw socket descriptor and returns whether the kernel close succeeded.

linuxIpv4Octets (fun)

fun linuxIpv4Octets(address: string): array<int>

Parses dotted-decimal address. Exactly four results indicate success. A result of any other length is invalid.

linuxPollSocket (fun)

trusted fun linuxPollSocket(
    descriptor: int,
    read: bool,
    write: bool,
    timeoutMilliseconds: int
): SocketPollResult

Polls descriptor for the requested read and write events. Uses timeoutMilliseconds in 0–600000 and reports readiness, closure, timeout or positive errno.

TcpConnection.poll (extension fun)

fun TcpConnection.poll(
    timeoutMilliseconds: int,
    read: bool = true,
    write: bool = false
): SocketPollResult

Waits for the selected read or write readiness for up to timeoutMilliseconds. The result reports ready flags, closure, timeout, or a system error. Timeouts outside 0–600000 ms return error 22.

UdpSocket.poll (extension fun)

fun UdpSocket.poll(
    timeoutMilliseconds: int,
    read: bool = true,
    write: bool = false
): SocketPollResult

Returns the requested readiness flags or reports a timeout or kernel error.

socketPoller (fun)

trusted fun socketPoller(): SocketPoller

Creates a close-on-exec poller. Returns a negative descriptor if the kernel call fails.

linuxPollerControl (fun)

trusted fun linuxPollerControl(
    poller: SocketPoller,
    operation: int,
    descriptor: int,
    read: bool,
    write: bool
): bool

Returns true if the kernel poller accepts the descriptor operation with the requested readiness interests.

SocketPoller.watchDescriptor (extension fun)

fun SocketPoller.watchDescriptor(
    descriptor: int,
    read: bool = true,
    write: bool = false
): bool

Adds descriptor to the poller with the requested read and write interests. Returns false if registration fails.

SocketPoller.modifyDescriptor (extension fun)

fun SocketPoller.modifyDescriptor(
    descriptor: int,
    read: bool = true,
    write: bool = false
): bool

Changes the watched descriptor to the requested read and write interests. Returns false if modification fails.

SocketPoller.unwatchDescriptor (extension fun)

fun SocketPoller.unwatchDescriptor(descriptor: int): bool

Removes descriptor from the poller without closing it. Returns false if removal fails.

SocketPoller.wait (extension fun)

trusted fun SocketPoller.wait(
    maximumEvents: int = 64,
    timeoutMilliseconds: int = 5000
): SocketEvents

Returns up to maximumEvents readiness events, waiting at most timeoutMilliseconds. The result distinguishes a timeout and a system error. Valid limits are 1–1024 events and 0–600000 ms.

SocketPoller.close (extension fun)

fun SocketPoller.close(): bool

Closes the poller descriptor without closing watched descriptors. Returns true if closed or already closed.

tcpConnectIpv4 (fun)

trusted fun tcpConnectIpv4(
    address: string,
    port: int,
    timeoutMilliseconds: int
): TcpConnection

Bounded numeric-IPv4 client connection for low-level and compile-provider use. Nonblocking connect + poll prevents an unreachable peer from stalling the compiler or a service indefinitely; DNS remains a portable higher layer. Connects to the numeric IPv4 address and port within timeoutMilliseconds. The timeout must be 1–10000 ms and the port 1–65535. Failure returns a connection with a negative descriptor.

tcpConnect (fun)

fun tcpConnect(
    address: Ipv4SocketAddress,
    timeoutMilliseconds: int = 5000
): TcpConnection

Connects to the supplied IPv4 socket address within timeoutMilliseconds. A negative descriptor indicates invalid input, timeout, or another connection failure.

tcpConnectIpv6 (fun)

trusted fun tcpConnectIpv6(
    address: Ipv6SocketAddress,
    timeoutMilliseconds: int = 5000
): TcpConnection

Returns a connected IPv6 TCP socket, or a negative descriptor on invalid arguments, timeout, or failure.

TcpConnection.readWithTimeout (extension fun)

trusted fun TcpConnection.readWithTimeout(
    maximum: int,
    timeoutMilliseconds: int
): string

Waits for readability, then reads up to maximum bytes. Returns an empty string on EOF, timeout, error, or invalid limits. The byte limit must be 1–1048576 and timeoutMilliseconds must be positive.

TcpConnection.readWithTimeoutResult (extension fun)

fun TcpConnection.readWithTimeoutResult(
    maximum: int,
    timeoutMilliseconds: int
): SocketReadResult

Waits up to timeoutMilliseconds for readiness before reading up to maximum bytes. Returns a timeout result when polling expires, and preserves read and poll errors.

TcpConnection.readNetwork (extension fun)

fun TcpConnection.readNetwork(
    maximum: int,
    timeoutMilliseconds: int,
    cancellation: NetworkCancellation = networkCancellation(),
    cancellationPollMilliseconds: int = 50
): NetworkReadOutcome

Returns bounded TCP read data or the portable outcome for EOF, cancellation, timeout, or failure.

tcpListenAddress (fun)

trusted fun tcpListenAddress(
    socketAddress: Ipv4SocketAddress,
    backlog: int = 128,
    reusePort: bool = false
): TcpListener

Binds and listens at IPv4 socketAddress using backlog (1–4096) and optional reusePort. Port zero asks the kernel for a free port. On failure the listener's descriptor holds negative errno.

tcpListenIpv6 (fun)

trusted fun tcpListenIpv6(
    socketAddress: Ipv6SocketAddress,
    backlog: int = 128,
    dualStack: bool = true,
    reusePort: bool = false
): TcpListener

Returns a TCP listener bound to the IPv6 endpoint, or a negative descriptor when validation, bind, or listen fails.

tcpListen (fun)

trusted fun tcpListen(
    port: int,
    backlog: int = 128,
    reusePort: bool = false
): TcpListener

Opens a TCP listener on all IPv4 interfaces at port. backlog sets the pending connection queue and reusePort requests port sharing. A negative descriptor indicates failure.

linuxTcpAcceptDescriptor (fun)

trusted fun linuxTcpAcceptDescriptor(listenerDescriptor: int): int

Returns a close-on-exec client descriptor, retrying interrupted accepts and returning a negative result on failure.

TcpListener.accept (extension fun)

fun TcpListener.accept(): TcpConnection

Accepts one client. Returns a connection with a negative descriptor if the accept fails.

linuxSocketAddress (fun)

trusted fun linuxSocketAddress(
    descriptor: int,
    peer: bool
): Ipv4SocketAddress

Returns the local or peer IPv4 address for the descriptor, with port -1 if the lookup fails.

TcpListener.localAddress (extension fun)

fun TcpListener.localAddress(): Ipv4SocketAddress

Returns the listener's bound IPv4 address, with port -1 if it cannot be read.

TcpListener.localPort (extension fun)

trusted fun TcpListener.localPort(): int

Returns the bound port, including a port selected by the kernel. Returns -1 if the address lookup fails.

TcpConnection.localAddress (extension fun)

fun TcpConnection.localAddress(): Ipv4SocketAddress

Returns the connection's local IPv4 address, with port -1 if it cannot be read.

TcpConnection.peerAddress (extension fun)

fun TcpConnection.peerAddress(): Ipv4SocketAddress

Returns the peer's IPv4 address and port, or an empty address with port -1 on lookup failure.

linuxSocketAddressIpv6 (fun)

trusted fun linuxSocketAddressIpv6(
    descriptor: int,
    peer: bool
): Ipv6SocketAddress

Returns the local or peer IPv6 address, with port -1 if the lookup fails or the socket is another family.

TcpListener.localAddressIpv6 (extension fun)

fun TcpListener.localAddressIpv6(): Ipv6SocketAddress

Returns the listener's bound IPv6 address, with port -1 if unavailable.

TcpConnection.localAddressIpv6 (extension fun)

fun TcpConnection.localAddressIpv6(): Ipv6SocketAddress

Returns the connection's local IPv6 address, with port -1 if unavailable.

TcpConnection.peerAddressIpv6 (extension fun)

fun TcpConnection.peerAddressIpv6(): Ipv6SocketAddress

Returns the connection's peer IPv6 address, with port -1 if unavailable.

socketPeerAddress (fun)

trusted fun socketPeerAddress(descriptor: int): SocketPeerAddress?

Peer address from the socket itself, or null for a non-IP socket or error.

linuxSocketSetNonblocking (fun)

trusted fun linuxSocketSetNonblocking(descriptor: int, enabled: bool): bool

Returns true if the descriptor's nonblocking flag was updated successfully.

linuxSocketSetTimeouts (fun)

trusted fun linuxSocketSetTimeouts(
    descriptor: int,
    readMilliseconds: int,
    writeMilliseconds: int
): bool

SO_RCVTIMEO and SO_SNDTIMEO: how long one blocking read or write of this socket may wait, 0 for as long as it takes. It also covers calls made on the socket by a library such as OpenSSL.

linuxSocketTimeout (fun)

trusted fun linuxSocketTimeout(descriptor: int, option: int): int

SO_RCVTIMEO (20) or SO_SNDTIMEO (21) in milliseconds; 0 for none.

linuxSocketSetTimeout (fun)

trusted fun linuxSocketSetTimeout(descriptor: int, option: int, milliseconds: int): bool

Returns true if the socket accepts the chosen timeout option and duration.

linuxSocketHasTimeouts (fun)

fun linuxSocketHasTimeouts(descriptor: int): bool

Whether either timeout has been set on this socket.

linuxSocketTimeoutMilliseconds (fun)

trusted fun linuxSocketTimeoutMilliseconds(descriptor: int, option: int): int

The receive (option 20) or send (option 21) timeout the socket has, in milliseconds; 0 for none.

linuxBrokenPipeHold (fun)

trusted fun linuxBrokenPipeHold(): bool

A write to a socket the peer reset raises SIGPIPE, unless it passes MSG_NOSIGNAL, which OpenSSL's write(2) can't. Hold SIGPIPE around such a call so that it fails with EPIPE, then release it: the caller's mask and handler, which also decide what happens to its own writes to a closed pipe, stay as they were. The signal goes to the writing thread, and the mask is per thread. (Darwin sockets carry SO_NOSIGPIPE, so nothing is raised there.) The result is for linuxBrokenPipeRelease: whether it was blocked already.

linuxBrokenPipeRelease (fun)

trusted fun linuxBrokenPipeRelease(blockedBefore: bool): void

Restores the caller's SIGPIPE mask after a protected write, draining a pending signal when previously unblocked.

TcpListener.setNonblocking (extension fun)

fun TcpListener.setNonblocking(enabled: bool = true): bool

Enables or clears nonblocking mode according to enabled. Returns whether the listener flag update succeeded.

TcpConnection.setTimeouts (extension fun)

fun TcpConnection.setTimeouts(
    readMilliseconds: int,
    writeMilliseconds: int
): bool

Bounds each blocking read and write; see linuxSocketSetTimeouts.

TcpConnection.setNonblocking (extension fun)

fun TcpConnection.setNonblocking(enabled: bool = true): bool

Enables or clears nonblocking mode according to enabled. Returns whether the socket flag update succeeded.

TcpConnection.setNoDelay (extension fun)

trusted fun TcpConnection.setNoDelay(enabled: bool = true): bool

TCP_NODELAY (enabled) or Nagle's algorithm (false) on the connection: with Nagle a small write waits for the ACK of the previous one, and a peer that delays its ACKs (Linux up to 40 ms) makes a request-response protocol that writes its answer in two pieces (an HTTP/2 HEADERS frame and then DATA) stall. Servers set it on every accepted connection.

linuxSocketNoDelay (fun)

trusted fun linuxSocketNoDelay(descriptor: int): bool

Whether TCP_NODELAY is set on the socket descriptor (false when it is not a TCP socket).

UdpSocket.setNonblocking (extension fun)

fun UdpSocket.setNonblocking(enabled: bool = true): bool

Returns true if the socket's nonblocking flag was updated successfully.

TcpListener.close (extension fun)

fun TcpListener.close(): bool

Closes the listening socket. Returns true on success or when it was already closed, and false on close failure.

TcpConnection.readResult (extension fun)

trusted fun TcpConnection.readResult(maximum: int = 65536): SocketReadResult

Reads up to maximum bytes and distinguishes data, EOF, and a system error. A limit outside 1–1048576 bytes reports error 22 on an open connection.

ablaLinuxTcpReadCompact (fun)

trusted fun ablaLinuxTcpReadCompact(
    descriptor: int,
    maximum: int
): string

Returns up to the requested positive byte limit or empty text on EOF or read failure.

ablaLinuxTcpWriteCompact (fun)

trusted fun ablaLinuxTcpWriteCompact(
    descriptor: int,
    contents: string,
    offset: int
): int

Returns the result of sending bytes from the given offset in one vectored write, or zero when no bytes remain.

TcpConnection.readCompact (extension fun)

fun TcpConnection.readCompact(maximum: int = 4096): string

Optimized readiness-loop read with bounded native storage. The buffer is allocated dynamically, so it shares the ordinary reader's 1 MiB limit. Empty output represents EOF or a nonblocking retry; event poll flags retain the detailed close/error state.

TcpConnection.writeCompact (extension fun)

fun TcpConnection.writeCompact(
    contents: string,
    offset: int = 0
): SocketWriteResult

Sends bytes from contents starting at offset and reports the byte count and status. An invalid offset or closed connection returns error 22.

ablaLinuxPollWaitCompact (fun)

trusted fun ablaLinuxPollWaitCompact(
    descriptor: int,
    maximumEvents: int,
    timeoutMilliseconds: int
): string

Returns packed kernel event records or empty text on timeout or a polling error.

SocketPoller.waitCompact (extension fun)

fun SocketPoller.waitCompact(
    maximumEvents: int = 64,
    timeoutMilliseconds: int = 5000
): string

Packed 12-byte epoll-compatible records for allocation-sensitive event loops. The regular wait method remains the structured public interface.

TcpConnection.read (extension fun)

trusted fun TcpConnection.read(maximum: int = 65536): string

Keep the compatibility fast path allocation-free. Besides being cheaper for HTTP, this lets syscall-only servers remain free of hosted capability symbols. Call readResult when EOF/error distinction is required.

TcpConnection.writeResult (extension fun)

trusted fun TcpConnection.writeResult(contents: string): SocketWriteResult

Attempts to send all contents. Returns the number of bytes already sent and any system error, including on partial writes.

TcpConnection.writeNetwork (extension fun)

fun TcpConnection.writeNetwork(
    contents: string,
    timeoutMilliseconds: int,
    cancellation: NetworkCancellation = networkCancellation(),
    cancellationPollMilliseconds: int = 50
): NetworkWriteOutcome

Returns the portable TCP write outcome, including partial progress, cancellation, timeout, or failure.

TcpConnection.write (extension fun)

trusted fun TcpConnection.write(contents: string): int

Attempts to send all contents. Returns the byte count on success or -1 on failure. The peer may receive a prefix before failure.

TcpConnection.close (extension fun)

fun TcpConnection.close(): bool

Closes the socket. Returns true on success or when it was already closed, and false on close failure.

udpBind (fun)

trusted fun udpBind(
    address: Ipv4SocketAddress,
    reuseAddress: bool = true
): UdpSocket

Returns a UDP socket bound to the IPv4 address, or a negative descriptor if validation or binding fails.

udpBindPort (fun)

fun udpBindPort(port: int): UdpSocket

Binds a UDP socket on all IPv4 interfaces, or returns a negative descriptor if binding fails.

udpBindIpv6 (fun)

trusted fun udpBindIpv6(
    address: Ipv6SocketAddress,
    reuseAddress: bool = true,
    dualStack: bool = true
): UdpSocket

Returns a UDP socket bound to the IPv6 address, or a negative descriptor if validation or binding fails.

udpBindPortIpv6 (fun)

fun udpBindPortIpv6(port: int): UdpSocket

Binds a UDP socket on all IPv6 interfaces, or returns a negative descriptor if binding fails.

UdpSocket.localAddress (extension fun)

trusted fun UdpSocket.localAddress(): Ipv4SocketAddress

Returns the bound IPv4 address, with port -1 if the lookup fails.

UdpSocket.localPort (extension fun)

fun UdpSocket.localPort(): int

Returns the bound IPv4 port, or -1 if the lookup fails.

UdpSocket.localAddressIpv6 (extension fun)

fun UdpSocket.localAddressIpv6(): Ipv6SocketAddress

Returns the bound IPv6 address, with port -1 if unavailable.

UdpSocket.sendTo (extension fun)

trusted fun UdpSocket.sendTo(
    contents: string,
    destination: Ipv4SocketAddress
): SocketWriteResult

Sends an IPv4 datagram and returns the byte count or socket error in the write result.

UdpSocket.sendToIpv6 (extension fun)

trusted fun UdpSocket.sendToIpv6(
    contents: string,
    destination: Ipv6SocketAddress
): SocketWriteResult

Sends an IPv6 datagram and returns the byte count or socket error in the write result.

UdpSocket.receiveFromIpv6 (extension fun)

trusted fun UdpSocket.receiveFromIpv6(maximum: int = 65507): UdpDatagramIpv6

Returns one IPv6 datagram up to the byte limit, including truncation status or an error when receipt fails.

UdpSocket.receiveFrom (extension fun)

trusted fun UdpSocket.receiveFrom(maximum: int = 65507): UdpDatagram

Returns one IPv4 datagram up to the byte limit, including truncation status or an error when receipt fails.

UdpSocket.receiveFromWithTimeout (extension fun)

fun UdpSocket.receiveFromWithTimeout(
    maximum: int = 65507,
    timeoutMilliseconds: int = 5000
): UdpDatagram

Returns one IPv4 datagram or the timeout or socket error encountered while waiting or receiving.

UdpSocket.receiveFromIpv6WithTimeout (extension fun)

fun UdpSocket.receiveFromIpv6WithTimeout(
    maximum: int = 65507,
    timeoutMilliseconds: int = 5000
): UdpDatagramIpv6

Returns one IPv6 datagram or the timeout or socket error encountered while waiting or receiving.

UdpSocket.close (extension fun)

fun UdpSocket.close(): bool

Returns true if the socket was already closed or its descriptor closed successfully.

tcpEnableGracefulShutdown (fun)

trusted fun tcpEnableGracefulShutdown(): bool

Enables the kernel notification used for graceful shutdown. Returns whether setup succeeded.

SocketPoller.watchGracefulShutdown (extension fun)

fun SocketPoller.watchGracefulShutdown(): bool

Wake a readiness loop on SIGTERM instead of waiting for its idle timeout. The loop still consumes the notification through tcpShutdownRequested().

tcpShutdownRequested (fun)

fun tcpShutdownRequested(): bool

Checks and drains the graceful-shutdown notification. Returns true once a shutdown request has been seen.

TcpListener.acceptUntilShutdown (extension fun)

trusted fun TcpListener.acceptUntilShutdown(): TcpConnection

Waits for a client or shutdown and returns a connected descriptor, or a negative descriptor if stopping or accepting fails.

UnixSocketAddress (class)

class UnixSocketAddress(val name: string, val abstract: bool)

AF_UNIX streams. Path names are bytes; abstract names are Linux-only and may contain zero bytes. Closing a listener never unlinks its pathname.

UnixSocketAddress.isValid (method)

fun isValid(): bool

Returns true when the name fits the Unix address limit and a filesystem path is nonempty and contains no NUL.

unixSocketAddress (fun)

fun unixSocketAddress(path: string): UnixSocketAddress

Returns a filesystem Unix socket address for the supplied path bytes.

unixAbstractAddress (fun)

fun unixAbstractAddress(name: string): UnixSocketAddress

Returns a Linux abstract Unix socket address for the supplied name bytes.

UnixListener (class)

resource class UnixListener(var descriptor: int)

Owns a Unix listening descriptor, with a negative descriptor representing a failed or closed listener.

UnixListener.drop (method)

trusted fun drop(): void

Closes the owned Unix listening descriptor and marks it closed.

UnixConnection (class)

resource class UnixConnection(var descriptor: int)

Owns a connected Unix descriptor, with a negative descriptor representing a failed or closed connection.

UnixConnection.drop (method)

trusted fun drop(): void

Closes the owned Unix connection descriptor and marks it closed.

UnixConnection.read (extension fun)

fun UnixConnection.read(maximum: int = 65536): string

The temporary view shares the descriptor only during a call; disarm its destructor before returning so the Unix resource keeps sole ownership.

UnixConnection.readResult (extension fun)

fun UnixConnection.readResult(maximum: int = 65536): SocketReadResult

Returns read bytes, EOF, timeout, or an errno for a read on the Unix stream.

UnixConnection.write (extension fun)

fun UnixConnection.write(contents: string): int

Returns the number of bytes written to the Unix stream, which can be short on failure.

UnixConnection.writeResult (extension fun)

fun UnixConnection.writeResult(contents: string): SocketWriteResult

Returns the number of bytes written and status, including timeout or an error when sending fails.

UnixConnection.readWithTimeout (extension fun)

fun UnixConnection.readWithTimeout(maximum: int, timeoutMilliseconds: int): string

Returns available bytes within the limit and timeout, or empty text on EOF, timeout, or failure.

UnixConnection.readWithTimeoutResult (extension fun)

fun UnixConnection.readWithTimeoutResult(maximum: int, timeoutMilliseconds: int): SocketReadResult

Returns available bytes or the EOF, timeout, or error outcome for a bounded read.

UnixConnection.readCompact (extension fun)

fun UnixConnection.readCompact(maximum: int = 4096): string

Returns up to the requested bytes from the Unix stream, or empty text on EOF or read failure.

UnixConnection.writeCompact (extension fun)

fun UnixConnection.writeCompact(contents: string, offset: int = 0): SocketWriteResult

Returns the result of one compact write from a byte offset, including partial progress or an error.

UnixConnection.readNetwork (extension fun)

fun UnixConnection.readNetwork(maximum: int, timeoutMilliseconds: int,
    cancellation: NetworkCancellation = networkCancellation(),
    cancellationPollMilliseconds: int = 50): NetworkReadOutcome

Returns bounded Unix stream data or the portable outcome for EOF, cancellation, timeout, or failure.

UnixConnection.writeNetwork (extension fun)

fun UnixConnection.writeNetwork(contents: string, timeoutMilliseconds: int,
    cancellation: NetworkCancellation = networkCancellation(),
    cancellationPollMilliseconds: int = 50): NetworkWriteOutcome

Returns the portable Unix stream write outcome, including partial progress, cancellation, timeout, or failure.

UnixConnection.poll (extension fun)

fun UnixConnection.poll(timeoutMilliseconds: int, read: bool = true,
    write: bool = false): SocketPollResult

Returns the requested readiness flags or reports a timeout or kernel error.

UnixConnection.setTimeouts (extension fun)

fun UnixConnection.setTimeouts(readMilliseconds: int, writeMilliseconds: int): bool

Returns true if the connection accepts both the requested read and write timeouts.

UnixConnection.setNonblocking (extension fun)

fun UnixConnection.setNonblocking(enabled: bool = true): bool

Returns true if the connection's nonblocking flag was updated successfully.

UnixListener.setNonblocking (extension fun)

fun UnixListener.setNonblocking(enabled: bool = true): bool

Returns true if the listener's nonblocking flag was updated successfully.

UnixConnection.close (extension fun)

fun UnixConnection.close(): bool

Returns true if the connection was already closed or its descriptor closed successfully.

UnixListener.close (extension fun)

fun UnixListener.close(): bool

Returns true if the listener was already closed or its descriptor closed successfully.

UnixListener.accept (extension fun)

fun UnixListener.accept(): UnixConnection

Returns a connected Unix socket or a negative descriptor if accept fails.

unixListen (fun)

trusted fun unixListen(address: UnixSocketAddress, backlog: int = 128): UnixListener

Returns a listener on the Unix endpoint, or a negative descriptor for invalid arguments or a bind or listen failure.

unixConnect (fun)

trusted fun unixConnect(address: UnixSocketAddress, timeoutMilliseconds: int = 5000): UnixConnection

Returns a connected Unix socket or a negative descriptor for invalid arguments, timeout, or connection failure.

Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.