Tokio event loop


#1

I’m trying rust for non-blocking IO.
I have follow the example of https://tokio.rs/, but “core.run(server).unwrap();” is a blocking call, how should I do if I want to listen more ports in the same thread ?


#2

core.run() will drive the event loop. To listen to multiple ports you don’t need multiple event loops.
Instead you have to create one big future doing all the work, by combining other futures.

In your case you can for example create two TcpListeners and combine their incoming() connection stream with the select() method from the futures crate.


#3

Thanks. Let me try :bow: