I need to listen more than two udp sockets and call their recv_from method repeatly.
I currently use two threads holding one UdpSocket
each.
Is there any better methods?
For example is tokio async methods better?
I need to listen more than two udp sockets and call their recv_from method repeatly.
I currently use two threads holding one UdpSocket
each.
Is there any better methods?
For example is tokio async methods better?
"Multiple I/O sources with unpredictable timing" is a textbook case for async, so yes, Tokio will work fine. If your use case is simple enough and doesn't require integration with other services, so will any other runtime.
epoll
, poll
or select
can help you with that if you don't want to touch async.