Skip to content

Commit 617b13c

Browse files
authored
feat(net): TcpStream.nodelay, TcpStream.set_nodelay (#384)
1 parent f64cfd5 commit 617b13c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

compio-net/src/tcp.rs

+19
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,25 @@ impl TcpStream {
231231
pub fn into_poll_fd(self) -> io::Result<PollFd<Socket2>> {
232232
self.inner.into_poll_fd()
233233
}
234+
235+
/// Gets the value of the `TCP_NODELAY` option on this socket.
236+
///
237+
/// For more information about this option, see
238+
/// [`TcpStream::set_nodelay`].
239+
pub fn nodelay(&self) -> io::Result<bool> {
240+
self.inner.socket.nodelay()
241+
}
242+
243+
/// Sets the value of the TCP_NODELAY option on this socket.
244+
///
245+
/// If set, this option disables the Nagle algorithm. This means
246+
/// that segments are always sent as soon as possible, even if
247+
/// there is only a small amount of data. When not set, data is
248+
/// buffered until there is a sufficient amount to send out,
249+
/// thereby avoiding the frequent sending of small packets.
250+
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
251+
self.inner.socket.set_nodelay(nodelay)
252+
}
234253
}
235254

236255
impl AsyncRead for TcpStream {

0 commit comments

Comments
 (0)