Types
A shared TCP or Unix-domain client stream, created by std.net.connect or connect_unix. Closing any copy closes the connection for every copy.
_handle: NativeHandle | The native socket resource. |
|---|
Functions
Connects to a hostname or numeric IPv4/IPv6 address on port 1..65535. timeout_ms must be 1..4294967295 and bounds DNS plus connection setup. Failure to reserve deadline enforcement returns an error; it never falls back to an unbounded connection attempt.
Connects to a filesystem Unix-domain socket on POSIX systems. path must be nonempty, contain no NUL bytes, and fit the platform socket address limit. Relative paths resolve against the current working directory; paths are binary bytes and need not be UTF-8. timeout_ms bounds connection setup and must be 1..4294967295. Returns Unsupported on Windows.
Reads up to count binary bytes (0..67108864). A positive-count read returns an empty string at EOF; a zero-count read succeeds immediately. timeout_ms bounds the whole operation and must be 1..4294967295. A shared stream permits one read and one write concurrently; overlapping reads or overlapping writes return Busy. I/O failure or timeout closes the stream and interrupts the opposite direction, since bytes may already have been consumed. Argument errors and Busy leave the connection usable.
Writes every supplied binary byte and returns its byte count, including zero for an empty string. The maximum write is 67108864 bytes. timeout_ms bounds the entire write, including backpressure. I/O failure closes the stream; some bytes may already have reached the peer.
Closes all copies idempotently and interrupts pending I/O. Subsequent operations return Closed. An unreachable stream is also finalized.