pub struct TcpSession { /* private fields */ }Expand description
Tracks an active guest-originated TCP stream.
Implementations§
Source§impl TcpSession
impl TcpSession
Sourcepub async fn write_data(&self, data: Vec<u8>) -> Result<(), String>
pub async fn write_data(&self, data: Vec<u8>) -> Result<(), String>
Queue stream data to write to the guest socket.
Awaits queue space when the per-session relay is behind, so a stalled destination backpressures the caller instead of growing memory.
Sourcepub async fn close_write(&self) -> Result<(), String>
pub async fn close_write(&self) -> Result<(), String>
Close the guest socket write half.
Ordered after any queued data, so the destination sees the write shutdown only once it has received everything sent before it.
Sourcepub fn close(&self)
pub fn close(&self)
Tear down the TCP session.
Aborts the relay task directly rather than queuing a command, so teardown never waits behind a full command queue. Dropping the task closes the guest socket. The host has already closed its side before asking for this, so no terminal frame is owed back to it.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns whether the background relay task has finished.
Sourcepub fn open(
id: u32,
req: TcpConnect,
session_tx: &UnboundedSender<(u32, SessionOutput)>,
) -> Self
pub fn open( id: u32, req: TcpConnect, session_tx: &UnboundedSender<(u32, SessionOutput)>, ) -> Self
Open a TCP stream from inside the guest and start relaying it.
The OS connect runs inside the spawned task, not on the caller’s serial
loop, so a hanging or slow destination can never wedge the agent. The
task reports core.tcp.connected on success or a terminal
core.tcp.failed on error/timeout over session_tx; the host correlates
either reply by id. The returned session is live immediately, with
commands queued until the connect completes.