pub struct ClientSocket<T: IdentityType + Clone + 'static, AE: AsyncExecutor + 'static, CC: ClientConnectionHandler + 'static> { /* private fields */ }Expand description
Client-side TYPHOON socket providing send/receive operations.
Implementations§
Source§impl<T: IdentityType + Clone + 'static, AE: AsyncExecutor + 'static, CC: ClientConnectionHandler + 'static> ClientSocket<T, AE, CC>
impl<T: IdentityType + Clone + 'static, AE: AsyncExecutor + 'static, CC: ClientConnectionHandler + 'static> ClientSocket<T, AE, CC>
Sourcepub async fn send(
&self,
packet: DynamicByteBuffer,
) -> Result<(), ClientSocketError>
pub async fn send( &self, packet: DynamicByteBuffer, ) -> Result<(), ClientSocketError>
Send a packet using a pre-allocated buffer.
Sourcepub async fn send_bytes(&self, data: &[u8]) -> Result<(), ClientSocketError>
pub async fn send_bytes(&self, data: &[u8]) -> Result<(), ClientSocketError>
Send a byte slice, splitting into payload-sized chunks so each wire packet fits within MTU.
When fragmentation is unavoidable (remaining > max_data_payload), each
non-final chunk is sized in [max_data_payload * (1 - jitter), max_data_payload]
— jitter = TYPHOON_SEND_BYTES_JITTER (default 0.0, reproducing the
deterministic equal-chunk split). The final chunk and any single-packet
send go through unfragmented to avoid synthesising a small-packet tail
that a passive observer could latch onto.
Sourcepub fn max_data_payload(&self) -> usize
pub fn max_data_payload(&self) -> usize
Maximum user-data bytes per send call so the wire packet fits within MTU.
Sourcepub async fn receive(&self) -> Result<DynamicByteBuffer, ClientSocketError>
pub async fn receive(&self) -> Result<DynamicByteBuffer, ClientSocketError>
Receive a packet, returning the decrypted payload as a buffer.
Sourcepub async fn receive_bytes(&self) -> Result<Vec<u8>, ClientSocketError>
pub async fn receive_bytes(&self) -> Result<Vec<u8>, ClientSocketError>
Receive a packet, returning the decrypted payload as a byte vector.