@@ -53,6 +53,49 @@ pub trait TcpStreamExt: Sealed {
5353/// ``` 
5454#[ unstable( feature = "tcp_quickack" ,  issue = "96256" ) ]  
5555    fn  quickack ( & self )  -> io:: Result < bool > ; 
56+ 
57+     /// A socket listener will be awakened solely when data arrives. 
58+ /// 
59+ /// The `accept` argument set the delay in seconds until the 
60+ /// data is available to read, reducing the number of short lived 
61+ /// connections without data to process. 
62+ /// Contrary to other platforms `SO_ACCEPTFILTER` feature equivalent, there is 
63+ /// no necessity to set it after the `listen` call. 
64+ /// 
65+ /// See [`man 7 tcp`](https://man7.org/linux/man-pages/man7/tcp.7.html) 
66+ /// 
67+ /// # Examples 
68+ /// 
69+ /// ```no run 
70+ /// #![feature(tcp_deferaccept)] 
71+ /// use std::net::TcpStream; 
72+ /// use std::os::linux::net::TcpStreamExt; 
73+ /// 
74+ /// let stream = TcpStream::connect("127.0.0.1:8080") 
75+ ///         .expect("Couldn't connect to the server..."); 
76+ /// stream.set_deferaccept(1).expect("set_deferaccept call failed"); 
77+ /// ``` 
78+ #[ unstable( feature = "tcp_deferaccept" ,  issue = "none" ) ]  
79+     fn  set_deferaccept ( & self ,  accept :  u32 )  -> io:: Result < ( ) > ; 
80+ 
81+     /// Gets the accept delay value (in seconds) of the `TCP_DEFER_ACCEPT` option. 
82+ /// 
83+ /// For more information about this option, see [`TcpStreamExt::set_deferaccept`]. 
84+ /// 
85+ /// # Examples 
86+ /// 
87+ /// ```no_run 
88+ /// #![feature(tcp_deferaccept)] 
89+ /// use std::net::TcpStream; 
90+ /// use std::os::linux::net::TcpStreamExt; 
91+ /// 
92+ /// let stream = TcpStream::connect("127.0.0.1:8080") 
93+ ///         .expect("Couldn't connect to the server..."); 
94+ /// stream.set_deferaccept(1).expect("set_deferaccept call failed"); 
95+ /// assert_eq!(stream.deferaccept().unwrap_or(0), 1); 
96+ /// ``` 
97+ #[ unstable( feature = "tcp_deferaccept" ,  issue = "none" ) ]  
98+     fn  deferaccept ( & self )  -> io:: Result < u32 > ; 
5699} 
57100
58101#[ unstable( feature = "tcp_quickack" ,  issue = "96256" ) ]  
@@ -67,4 +110,12 @@ impl TcpStreamExt for net::TcpStream {
67110    fn  quickack ( & self )  -> io:: Result < bool >  { 
68111        self . as_inner ( ) . as_inner ( ) . quickack ( ) 
69112    } 
113+ 
114+     fn  set_deferaccept ( & self ,  accept :  u32 )  -> io:: Result < ( ) >  { 
115+         self . as_inner ( ) . as_inner ( ) . set_deferaccept ( accept) 
116+     } 
117+ 
118+     fn  deferaccept ( & self )  -> io:: Result < u32 >  { 
119+         self . as_inner ( ) . as_inner ( ) . deferaccept ( ) 
120+     } 
70121} 
0 commit comments