File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,11 @@ impl Socket {
206206 std:: mem:: forget ( s) ;
207207 result
208208 }
209+
210+ pub fn set_nodelay ( & self , nodelay : bool ) -> io:: Result < ( ) > {
211+ let socket_ref = socket2:: SockRef :: from ( self ) ;
212+ socket_ref. set_nodelay ( nodelay)
213+ }
209214}
210215
211216impl AsRawFd for Socket {
Original file line number Diff line number Diff line change @@ -207,6 +207,16 @@ impl TcpStream {
207207 pub fn shutdown ( & self , how : std:: net:: Shutdown ) -> io:: Result < ( ) > {
208208 self . inner . shutdown ( how)
209209 }
210+
211+ /// Sets the value of the TCP_NODELAY option on this socket.
212+ ///
213+ /// If set, this option disables the Nagle algorithm. This means that segments are always sent
214+ /// as soon as possible, even if there is only a small amount of data. When not set, data is
215+ /// buffered until there is a sufficient amount to send out, thereby avoiding the frequent
216+ /// sending of small packets.
217+ pub fn set_nodelay ( & self , nodelay : bool ) -> io:: Result < ( ) > {
218+ self . inner . set_nodelay ( nodelay)
219+ }
210220}
211221
212222impl FromRawFd for TcpStream {
You can’t perform that action at this time.
0 commit comments