Skip to main content

Module socket_transport

Module socket_transport 

Source
Expand description

Socket-backed P9Transport — a native 9P transport over a byte stream.

This is the client-side counterpart to the server-side Translator accept loop: where the translator reads length-prefixed 9P frames off a tokio::net stream and dispatches them to a Backend, SocketTransport carries complete 9P frames between a P9Client and a remote 9P2000.L server over the same wire (a Unix domain socket or TCP). It is the inverse of the DMA transport ([crate::dma]): identical P9Transport contract, but a real OS socket instead of a SharedArrayBuffer ring, so it carries across process (and host) boundaries.

§Framing contract

P9Client hands send a complete 9P message whose first four bytes are the self-counting size[4] field, and expects recv to return exactly one such complete frame. recv therefore reads the 4-byte length prefix first, then the size - 4 remaining body bytes, handling partial reads via read_exact — matching the framing the Translator itself uses on the server side.

§Concurrency

The read and write halves each sit behind their own async Mutex, so the transport is Send + Sync. Whole request/response pairs are serialized one level up (in Remote9pMount, which holds the P9Client behind a single mutex), which is what keeps interleaved T-messages from racing on one connection.

Structs§

SocketTransport
A P9Transport backed by an AsyncRead + AsyncWrite byte stream.