Skip to main content
function UnixStream.close
def UnixStream.close() -> None
Close the stream. A TLS stream tells its peer first. Closing twice is harmless; any other use after closing fails. A stream that is dropped closes by itself. function UnixStream.flush
def UnixStream.flush() -> None
Send whatever is buffered. A TLS stream buffers the records it encrypts; a plain socket has nothing to flush. function UnixStream.local_addr
def UnixStream.local_addr() -> None | str
The path this end is bound to, or None for an unnamed socket. function UnixStream.peer_addr
def UnixStream.peer_addr() -> None | str
The path the peer is bound to, or None for an unnamed socket, as a connecting client’s usually is. function UnixStream.read
def UnixStream.read(
n: int,
/
) -> bytes
Read at most n bytes, and at most 64 KiB: whatever arrives first, at least one byte unless the peer has closed its end, where it returns b"". Call it again for more. function UnixStream.read_exact
def UnixStream.read_exact(
n: int,
/
) -> bytes
Read exactly n bytes. A peer that closes first fails it with kind == "unexpected_eof". function UnixStream.read_to_end
def UnixStream.read_to_end() -> bytes
Read until the peer closes its end. function UnixStream.read_to_string
def UnixStream.read_to_string() -> str
Read until the peer closes its end, as text. Bytes that are not UTF-8 fail it with kind == "invalid_data". function UnixStream.set_read_timeout
def UnixStream.set_read_timeout(
timeout_ms: None | int,
/
) -> None
Fail any later read that waits longer than timeout_ms with kind == "timed_out". None waits as long as the OS does. function UnixStream.set_write_timeout
def UnixStream.set_write_timeout(
timeout_ms: None | int,
/
) -> None
Fail any later write that waits longer than timeout_ms with kind == "timed_out". None waits as long as the OS does. function UnixStream.shutdown
def UnixStream.shutdown(
how: str,
/
) -> None
Shut down the "read" half, the "write" half, or "both". After shutting down writes, the peer reads the end of the stream: the way to tell a peer that waits for it that the request is complete. A TLS stream tells its peer first, so the end is not mistaken for a cut. function UnixStream.try_flush
def UnixStream.try_flush() -> (None | std.io.Error, None)
flush, returning an (err, None) pair instead of raising a std.io.Error. function UnixStream.try_local_addr
def UnixStream.try_local_addr() -> (None | std.io.Error, None | str)
local_addr, returning an (err, str | None) pair instead of raising a std.io.Error. function UnixStream.try_peer_addr
def UnixStream.try_peer_addr() -> (None | std.io.Error, None | str)
peer_addr, returning an (err, str | None) pair instead of raising a std.io.Error. function UnixStream.try_read
def UnixStream.try_read(
n: int,
/
) -> (None | std.io.Error, None | bytes)
read, returning an (err, bytes) pair instead of raising a std.io.Error. function UnixStream.try_read_exact
def UnixStream.try_read_exact(
n: int,
/
) -> (None | std.io.Error, None | bytes)
read_exact, returning an (err, bytes) pair instead of raising a std.io.Error. function UnixStream.try_read_to_end
def UnixStream.try_read_to_end() -> (None | std.io.Error, None | bytes)
read_to_end, returning an (err, bytes) pair instead of raising a std.io.Error. function UnixStream.try_read_to_string
def UnixStream.try_read_to_string() -> (None | std.io.Error, None | str)
read_to_string, returning an (err, str) pair instead of raising a std.io.Error. function UnixStream.try_set_read_timeout
def UnixStream.try_set_read_timeout(
timeout_ms: None | int,
/
) -> (None | std.io.Error, None)
set_read_timeout, returning an (err, None) pair instead of raising a std.io.Error. function UnixStream.try_set_write_timeout
def UnixStream.try_set_write_timeout(
timeout_ms: None | int,
/
) -> (None | std.io.Error, None)
set_write_timeout, returning an (err, None) pair instead of raising a std.io.Error. function UnixStream.try_shutdown
def UnixStream.try_shutdown(
how: str,
/
) -> (None | std.io.Error, None)
shutdown, returning an (err, None) pair instead of raising a std.io.Error. function UnixStream.try_write
def UnixStream.try_write(
data: bytes | str,
/
) -> (None | std.io.Error, None | int)
write, returning an (err, int) pair instead of raising a std.io.Error. function UnixStream.try_write_all
def UnixStream.try_write_all(
data: bytes | str,
/
) -> (None | std.io.Error, None)
write_all, returning an (err, None) pair instead of raising a std.io.Error. function UnixStream.write
def UnixStream.write(
data: bytes | str,
/
) -> int
Write some of data and return how many bytes were written, which can be fewer than len(data). Use write_all to write all of it. function UnixStream.write_all
def UnixStream.write_all(
data: bytes | str,
/
) -> None
Write all of data, a string or bytes.