Context: UdpSocket in tokio::net - Rust
XY problem: I want to create a udp socket, then fire off a new async task for each remote_addr that talks to the socket (with a timeout of say, kill the task if no msg for 3 minutes).
The documentation for connect states:
Connects the UDP socket setting the default destination for send() and limiting packets that are read via recv from the address specified in
addr
This is great, but I need something stronger -- namely that all udp packets that are from given remote_addr are guaranteed to hit this socket.
One can imagine a layout that looks something like this:
async fn main() -> io::Result<()> {
let sock = UdpSocket::bind("0.0.0.0:8080").await?;
let mut buf = [0; 1024];
loop {
let (len, addr) = sock.recv_from(&mut buf).await?;
creates a new task, based on remote_addr, use connect;
}
}
My concern is: can the "recv_from" from the original sock consume packets meant for the task dedicated to remote_addr ?