unienv_interface.remote.transport¶
Frame transports: TCP and Unix stream sockets, WebSocket, and in-memory pairs.
Addresses are URLs: tcp://host:port, unix:///path/to.sock and
ws://host:port. Port 0 picks a free port. Every transport sends one
frame per :meth:Transport.send (thread-safe) and returns
(json, buffers) from :meth:Transport.recv (one reader thread).
Transport
¶
A reliable, ordered connection carrying whole frames.
send
¶
send(parts: Sequence[Any], size: int) -> None
Send the frame parts (size bytes in total). Thread-safe.
StreamTransport
¶
StreamTransport(sock: socket, max_frame_size: int = DEFAULT_MAX_FRAME_SIZE)
MemoryTransport
¶
MemoryTransport(incoming: _Queue, outgoing: _Queue, max_frame_size: int = DEFAULT_MAX_FRAME_SIZE)
WebSocketTransport
¶
WebSocketTransport(connection: Any, max_frame_size: int = DEFAULT_MAX_FRAME_SIZE)
Listener
¶
parse_address
¶
parse_address(address: str) -> Tuple[str, str, Optional[int]]
Return (scheme, host or path, port) for a transport URL.
connect
¶
connect(address: str, *, timeout: Optional[float] = 10.0, max_frame_size: int = DEFAULT_MAX_FRAME_SIZE) -> Transport
Open a client transport to address.
listen
¶
listen(address: str, *, on_connect: Callable[[Transport], None], serve_connection: Callable[[Transport], None], max_frame_size: int = DEFAULT_MAX_FRAME_SIZE) -> Listener
Start accepting connections on address.
Stream connections are handed to on_connect (which must not block);
WebSocket connections run serve_connection on the library's handler thread.