File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -1807,6 +1807,46 @@ 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(
1816+ feature = "all" ,
1817+ any( target_os = "android" , target_os = "linux" )
1818+ ) ) ]
1819+ pub fn tcp_notsent_lowat ( & self ) -> io:: Result < u32 > {
1820+ unsafe {
1821+ getsockopt :: < Bool > (
1822+ self . as_raw ( ) ,
1823+ libc:: IPPROTO_TCP ,
1824+ libc:: TCP_NOTSENT_LOWAT ,
1825+ )
1826+ . map ( |lowat| lowat as u32 )
1827+ }
1828+ }
1829+
1830+
1831+ /// Set the value of the `TCP_NOTSENT_LOWAT` option on this socket.
1832+ ///
1833+ /// If set the kernel will limit the amount of _unsent_ data in the sendbuffer.
1834+ /// This differs from `set_send_buffer_size` which limits the sum of unsent and unacknowledged data.
1835+ #[ cfg( all(
1836+ feature = "all" ,
1837+ any( target_os = "android" , target_os = "linux" )
1838+ ) ) ]
1839+ pub fn set_tcp_notsent_lowat ( & self , lowat : u32 ) -> io:: Result < ( ) > {
1840+ unsafe {
1841+ setsockopt (
1842+ self . as_raw ( ) ,
1843+ libc:: IPPROTO_TCP ,
1844+ libc:: TCP_NOTSENT_LOWAT ,
1845+ lowat as c_int ,
1846+ )
1847+ }
1848+ }
1849+
18101850 /// Gets the value for the `SO_BINDTODEVICE` option on this socket.
18111851 ///
18121852 /// This value gets the socket binded device's interface name.
Original file line number Diff line number Diff line change @@ -1458,6 +1458,11 @@ 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(
1462+ feature = "all" ,
1463+ any( target_os = "android" , target_os = "linux" )
1464+ ) ) ]
1465+ test ! ( tcp_notsent_lowat, set_tcp_notsent_lowat( 16 * 1024 ) ) ;
14611466test ! ( linger, set_linger( Some ( Duration :: from_secs( 10 ) ) ) ) ;
14621467test ! (
14631468 read_timeout,
You can’t perform that action at this time.
0 commit comments