Skip to main content
function TlsStream.close
def TlsStream.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 TlsStream.flush
def TlsStream.flush() -> None
Send whatever is buffered. A TLS stream buffers the records it encrypts; a plain socket has nothing to flush. function TlsStream.local_addr
def TlsStream.local_addr() -> str
This end’s address, as "ip:port". function TlsStream.peer_addr
def TlsStream.peer_addr() -> str
The peer’s address, as "ip:port". function TlsStream.read
def TlsStream.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 TlsStream.read_exact
def TlsStream.read_exact(
n: int,
/
) -> bytes
Read exactly n bytes. A peer that closes first fails it with kind == "unexpected_eof". function TlsStream.read_to_end
def TlsStream.read_to_end() -> bytes
Read until the peer closes its end. function TlsStream.read_to_string
def TlsStream.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 TlsStream.set_nodelay
def TlsStream.set_nodelay(
on: bool,
/
) -> None
Turn Nagle’s algorithm off (True) so small writes go out at once, or back on (False). function TlsStream.set_read_timeout
def TlsStream.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 TlsStream.set_write_timeout
def TlsStream.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 TlsStream.shutdown
def TlsStream.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 TlsStream.try_flush
def TlsStream.try_flush() -> (None | std.io.Error, None)
flush, returning an (err, None) pair instead of raising a std.io.Error. function TlsStream.try_local_addr
def TlsStream.try_local_addr() -> (None | std.io.Error, None | str)
local_addr, returning an (err, str) pair instead of raising a std.io.Error. function TlsStream.try_peer_addr
def TlsStream.try_peer_addr() -> (None | std.io.Error, None | str)
peer_addr, returning an (err, str) pair instead of raising a std.io.Error. function TlsStream.try_read
def TlsStream.try_read(
n: int,
/
) -> (None | std.io.Error, None | bytes)
read, returning an (err, bytes) pair instead of raising a std.io.Error. function TlsStream.try_read_exact
def TlsStream.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 TlsStream.try_read_to_end
def TlsStream.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 TlsStream.try_read_to_string
def TlsStream.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 TlsStream.try_set_nodelay
def TlsStream.try_set_nodelay(
on: bool,
/
) -> (None | std.io.Error, None)
set_nodelay, returning an (err, None) pair instead of raising a std.io.Error. function TlsStream.try_set_read_timeout
def TlsStream.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 TlsStream.try_set_write_timeout
def TlsStream.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 TlsStream.try_shutdown
def TlsStream.try_shutdown(
how: str,
/
) -> (None | std.io.Error, None)
shutdown, returning an (err, None) pair instead of raising a std.io.Error. function TlsStream.try_write
def TlsStream.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 TlsStream.try_write_all
def TlsStream.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 TlsStream.write
def TlsStream.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 TlsStream.write_all
def TlsStream.write_all(
data: bytes | str,
/
) -> None
Write all of data, a string or bytes.