Stream
struct StreamA connected TCP socket. It's non-blocking, but write_all and read_into wait for it, so to its users it blocks; the head's loop uses send_some and recv_some, which don't. Closes itself when dropped.
Implements Movable
- Fields
fd: c_int
__init__
def __init__(out self, fd: Int32) __deinit__
def __deinit__(deinit self) connect
def connect(port: Int) -> Self Connects to 127.0.0.1:port.
def connect(host: String, port: Int) -> Self Connects to host:port; host is a name or a dotted quad.
def connect(ip: Array[UInt8, Int(4)], port: Int) -> Self Connects to ip:port.
local_ip
def local_ip(self) -> Array[UInt8, Int(4)] The local IPv4 address this connection goes out from.
write_all
def write_all(self, data: Span[UInt8]) Writes every byte of data.
read_into
def read_into(self, buf: Pointer[UInt8], size: Int) -> Int Reads exactly size bytes into buf.
Returns size, or 0 when the peer closed before sending anything.
Raises if the peer closes partway through.
close
def close(mut self)