File tree 1 file changed +16
-1
lines changed
tonic/src/transport/server
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,10 @@ use std::{
12
12
task:: { Context , Poll } ,
13
13
time:: Duration ,
14
14
} ;
15
- use tokio:: io:: { AsyncRead , AsyncWrite } ;
15
+ use tokio:: {
16
+ io:: { AsyncRead , AsyncWrite } ,
17
+ net:: TcpListener ,
18
+ } ;
16
19
17
20
#[ cfg( not( feature = "tls" ) ) ]
18
21
pub ( crate ) fn tcp_incoming < IO , IE , L > (
@@ -172,6 +175,18 @@ impl TcpIncoming {
172
175
inner. set_keepalive ( keepalive) ;
173
176
Ok ( TcpIncoming { inner } )
174
177
}
178
+
179
+ /// Creates a new `TcpIncoming` from an existing `tokio::net::TcpListener`.
180
+ pub fn from_listener (
181
+ listener : TcpListener ,
182
+ nodelay : bool ,
183
+ keepalive : Option < Duration > ,
184
+ ) -> Result < Self , crate :: Error > {
185
+ let mut inner = AddrIncoming :: from_listener ( listener) ?;
186
+ inner. set_nodelay ( nodelay) ;
187
+ inner. set_keepalive ( keepalive) ;
188
+ Ok ( TcpIncoming { inner } )
189
+ }
175
190
}
176
191
177
192
impl Stream for TcpIncoming {
You can’t perform that action at this time.
0 commit comments