1 | use futures::future::poll_fn; |
---|---|
2 | |
3 | fn main() { |
4 | let rt = tokio::runtime::Builder::new_multi_thread() |
5 | .worker_threads(1) |
6 | .enable_io() |
7 | .build() |
8 | .unwrap(); |
9 | |
10 | rt.block_on(async { |
11 | let listener = tokio::net::TcpListener::bind("0.0.0.0:0").await.unwrap(); |
12 | tokio::spawn(async move { |
13 | loop { |
14 | poll_fn(|cx| listener.poll_accept(cx)).await.unwrap(); |
15 | } |
16 | }); |
17 | }); |
18 | |
19 | std::thread::sleep(std::time::Duration::from_millis(50)); |
20 | drop(rt); |
21 | } |
22 |