Skip to main content
function TcpListener.accept
def TcpListener.accept(
*,
timeout_ms: None | int = None
) -> (std.net.TcpStream, str)
Wait for a connection and return (stream, peer_addr). With timeout_ms, fail with kind == "timed_out" when none arrives in time; None waits for as long as it takes. function TcpListener.close
def TcpListener.close() -> None
Stop listening. Closing twice is harmless. A listener that is dropped closes by itself. function TcpListener.local_addr
def TcpListener.local_addr() -> str
The address this listener is bound to, as "ip:port": how to learn the port listen("127.0.0.1:0") picked. function TcpListener.try_accept
def TcpListener.try_accept(
*,
timeout_ms: None | int = None
) -> (None | std.io.Error, None | (std.net.TcpStream, str))
accept, returning an (err, (stream, peer_addr)) pair instead of raising a std.io.Error. function TcpListener.try_local_addr
def TcpListener.try_local_addr() -> (None | std.io.Error, None | str)
local_addr, returning an (err, str) pair instead of raising a std.io.Error.