@@ -1385,6 +1385,60 @@ impl crate::Socket {
13851385 }
13861386 }
13871387
1388+ /// Get the value of the `TCP_THIN_LINEAR_TIMEOUTS` option on this socket.
1389+ ///
1390+ /// For more information about this option, see [`set_thin_linear_timeouts`].
1391+ ///
1392+ /// [`set_thin_linear_timeouts`]: Socket::set_thin_linear_timeouts
1393+ #[ cfg( all(
1394+ feature = "all" ,
1395+ any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
1396+ ) ) ]
1397+ #[ cfg_attr(
1398+ docsrs,
1399+ doc( cfg( all(
1400+ feature = "all" ,
1401+ any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
1402+ ) ) )
1403+ ) ]
1404+ pub fn thin_linear_timeouts ( & self ) -> io:: Result < bool > {
1405+ unsafe {
1406+ getsockopt :: < Bool > (
1407+ self . as_raw ( ) ,
1408+ libc:: IPPROTO_TCP ,
1409+ libc:: TCP_THIN_LINEAR_TIMEOUTS ,
1410+ )
1411+ . map ( |timeouts| timeouts != 0 )
1412+ }
1413+ }
1414+
1415+ /// Set the value of the `TCP_THIN_LINEAR_TIMEOUTS` option on this socket.
1416+ ///
1417+ /// If set, the kernel will dynamically detect a thin-stream connection if there are less than four packets in flight.
1418+ /// With less than four packets in flight the normal TCP fast retransmission will not be effective.
1419+ /// The kernel will modify the retransmission to avoid the very high latencies that thin stream suffer because of exponential backoff.
1420+ #[ cfg( all(
1421+ feature = "all" ,
1422+ any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
1423+ ) ) ]
1424+ #[ cfg_attr(
1425+ docsrs,
1426+ doc( cfg( all(
1427+ feature = "all" ,
1428+ any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
1429+ ) ) )
1430+ ) ]
1431+ pub fn set_thin_linear_timeouts ( & self , timeouts : bool ) -> io:: Result < ( ) > {
1432+ unsafe {
1433+ setsockopt (
1434+ self . as_raw ( ) ,
1435+ libc:: IPPROTO_TCP ,
1436+ libc:: TCP_THIN_LINEAR_TIMEOUTS ,
1437+ timeouts as c_int ,
1438+ )
1439+ }
1440+ }
1441+
13881442 /// Gets the value for the `SO_BINDTODEVICE` option on this socket.
13891443 ///
13901444 /// This value gets the socket binded device's interface name.
0 commit comments