Skip to main content
function Tcp.connect
def Tcp.connect(
addr: str,
/,
*,
timeout_ms: None | int = None
) -> std.net.TcpStream
Connect to addr, "host:port" (an IPv6 host in brackets: "[::1]:6379"). Each address the host resolves to is tried in turn, all within timeout_ms, which bounds the name lookup too; None waits as long as the OS does. A failure raises std.io.Error, e.g. kind == "connection_refused" or "timed_out". function Tcp.listen
def Tcp.listen(
addr: str,
/
) -> std.net.TcpListener
Listen on addr, "host:port". Port 0 picks a free port; the listener’s local_addr() says which. function Tcp.try_connect
def Tcp.try_connect(
addr: str,
/,
*,
timeout_ms: None | int = None
) -> (None | std.io.Error, None | std.net.TcpStream)
connect, returning an (err, stream) pair instead of raising a std.io.Error. function Tcp.try_listen
def Tcp.try_listen(
addr: str,
/
) -> (None | std.io.Error, None | std.net.TcpListener)
listen, returning an (err, listener) pair instead of raising a std.io.Error.