pub struct TcpCork { /* private fields */ }Expand description
TCP Cork (batch small writes into single packet)
Buffers small writes and flushes them as a single TCP segment when the
buffer exceeds max_pending bytes or when flush() is called explicitly.
Implementations§
Source§impl TcpCork
impl TcpCork
Sourcepub fn with_socket(
max_pending: usize,
socket_id: usize,
remote: SocketAddr,
) -> Self
pub fn with_socket( max_pending: usize, socket_id: usize, remote: SocketAddr, ) -> Self
Create a TCP cork bound to a specific socket
Sourcepub fn write(&mut self, data: &[u8]) -> Result<(), KernelError>
pub fn write(&mut self, data: &[u8]) -> Result<(), KernelError>
Add data (may not send immediately)
Sourcepub fn pending_len(&self) -> usize
pub fn pending_len(&self) -> usize
Get the current pending data size
Sourcepub fn flush(&mut self) -> Result<(), KernelError>
pub fn flush(&mut self) -> Result<(), KernelError>
Force send pending data via TCP.
If a socket ID and remote address are configured, sends through the TCP
stack using tcp::transmit_data(). Otherwise, clears the buffer (useful
for testing or when the cork is used standalone).