File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1807,6 +1807,35 @@ impl crate::Socket {
18071807 }
18081808 }
18091809
1810+ /// Get the value of the `TCP_NOTSENT_LOWAT` option on this socket.
1811+ ///
1812+ /// For more information about this option, see [`set_tcp_notsent_lowat`].
1813+ ///
1814+ /// [`set_tcp_notsent_lowat`]: crate::Socket::set_tcp_notsent_lowat
1815+ #[ cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) ]
1816+ pub fn tcp_notsent_lowat ( & self ) -> io:: Result < u32 > {
1817+ unsafe {
1818+ getsockopt :: < Bool > ( self . as_raw ( ) , libc:: IPPROTO_TCP , libc:: TCP_NOTSENT_LOWAT )
1819+ . map ( |lowat| lowat as u32 )
1820+ }
1821+ }
1822+
1823+ /// Set the value of the `TCP_NOTSENT_LOWAT` option on this socket.
1824+ ///
1825+ /// If set the kernel will limit the amount of _unsent_ data in the sendbuffer.
1826+ /// This differs from `set_send_buffer_size` which limits the sum of unsent and unacknowledged data.
1827+ #[ cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) ]
1828+ pub fn set_tcp_notsent_lowat ( & self , lowat : u32 ) -> io:: Result < ( ) > {
1829+ unsafe {
1830+ setsockopt (
1831+ self . as_raw ( ) ,
1832+ libc:: IPPROTO_TCP ,
1833+ libc:: TCP_NOTSENT_LOWAT ,
1834+ lowat as c_int ,
1835+ )
1836+ }
1837+ }
1838+
18101839 /// Gets the value for the `SO_BINDTODEVICE` option on this socket.
18111840 ///
18121841 /// This value gets the socket binded device's interface name.
Original file line number Diff line number Diff line change @@ -1458,6 +1458,8 @@ test!(tcp_quickack, set_tcp_quickack(false));
14581458 any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
14591459) ) ]
14601460test ! ( tcp_thin_linear_timeouts, set_tcp_thin_linear_timeouts( true ) ) ;
1461+ #[ cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) ]
1462+ test ! ( tcp_notsent_lowat, set_tcp_notsent_lowat( 16 * 1024 ) ) ;
14611463test ! ( linger, set_linger( Some ( Duration :: from_secs( 10 ) ) ) ) ;
14621464test ! (
14631465 read_timeout,
You can’t perform that action at this time.
0 commit comments