std.net [core] std.net.Listener pub struct Listener { fd: int, } — A bound listener: the host socket this process accepts connections on. std.net.Socket pub struct Socket { fd: int, } — A connected socket: one end of an established stream, whichever side opened it and whichever address family carried it. std.net.listen pub fn listen(addr: str) -> Listener ! {io} — Bind a listening socket to addr and return it. std.net.port pub fn port(l: Listener) -> int ! {io} — The port l is bound to. std.net.accept pub fn accept(mut l: Listener) -> Socket ! {timeout, io} — Take the next connection from l's backlog, waiting until one arrives. std.net.connect pub fn connect(addr: str) -> Socket ! {refused, timeout, io} — Dial addr and return the connected socket. std.net.read pub fn read(mut s: Socket, max: int) -> str ! {closed, timeout, utf8, io} — Read up to max bytes from s, decoded as UTF-8, waiting for at least one byte. std.net.write pub fn write(mut s: Socket, text: str) -> () ! {closed, io} — Write all of text to s. std.net.read_bytes pub fn read_bytes(mut s: Socket, max: int) -> List[byte] ! {closed, timeout, io} — Read up to max BYTES from s as a List[byte] — the binary read. std.net.write_bytes pub fn write_bytes(mut s: Socket, b: List[byte]) -> () ! {closed, invalid, io} — Write all of b — raw bytes — to s. std.net.write_some pub fn write_some(mut s: Socket, b: List[byte]) -> int ! {busy, closed, invalid, io} — Send a prefix of b in one non-parking send, returning its byte count: at least 1 for non-empty b, 0 for empty b (the handle is still checked). std.net.set_deadline pub fn set_deadline(mut s: Socket, ms: int) -> () ! {io} — Arm (ms > 0) or clear (ms <= 0) a deadline BUDGET on s: every subsequent parking operation on this socket — read, read_bytes, write — resolves as its row's timeout tag when the budget fires first. std.net.set_listener_deadline pub fn set_listener_deadline(mut l: Listener, ms: int) -> () ! {io} — Arm (ms > 0) or clear (ms <= 0) a deadline budget on the LISTENER l: an accept whose peer never dials resolves timeout instead of blocking forever. std.net.close pub fn close(take s: Socket) -> () ! {io} — Close s, consuming it. std.net.close_listener pub fn close_listener(take l: Listener) -> () ! {io} — Close the listener l, consuming it. std.net.read_all pub fn read_all(mut s: Socket) -> str ! {timeout, utf8, io} — Every byte the peer sends until it closes, decoded as UTF-8, as one str. std.net.write_line pub fn write_line(mut s: Socket, text: str) -> () ! {closed, io} — Write text to s followed by exactly one "\n". std.net.read_lines pub fn read_lines(mut s: Socket) -> List[str] ! {timeout, utf8, io} — Every line the peer sends until it closes, terminators stripped. std.net.endpoint pub fn endpoint(host: str, port_number: int) -> str — host and port_number joined as the address string listen and connect take. std.net.loopback pub fn loopback(port_number: int) -> str — The loopback address with port_number — endpoint("127.0.0.1", n). std.net.Addr pub struct Addr { version: int, text: str, } — One address of a host: its IP version and its text — the element resolve will answer, and the part of a resolver std can fix before the call that makes one exists. std.net.ListenOpts pub struct ListenOpts { reuse_port: bool, backlog: int, } — The options listen_with takes: what a prefork server needs and nothing else. std.net.listen_opts pub fn listen_opts() -> ListenOpts — The options that make listen_with behave exactly like listen. std.net.listen_with pub fn listen_with(addr: str, opts: ListenOpts) -> Listener ! {unsupported, exists, denied, io} — Bind a listening socket to addr with opts and return it. std.net.adopt_listener pub fn adopt_listener(fd: int) -> Listener ! {unsupported, io} — Adopt a listening socket this process was HANDED rather than bound. std.net.wait pub fn wait(fds: List[int], deadline_ms: int) -> List[int] ! {io} — Which of fds can be read WITHOUT blocking, as a subset in the caller's order. std.net.writev pub fn writev(mut s: Socket, parts: List[List[byte]]) -> () ! {closed, io} — Write every part of parts to s, in order, as ONE write. std.net.nodelay pub fn nodelay(mut s: Socket, on: bool) -> () ! {io} — Set Nagle's algorithm off (on = true) or on (on = false) for s.