How to remotely shut down running tasks with Tokio
问题 I have a UDP socket that is receiving data pub async fn start() -> Result<(), std::io::Error> { loop { let mut data = vec![0; 1024]; socket.recv_from(&mut data).await?; } } This code is currently blocked on the .await when there is no data coming in. I want to gracefully shut down my server from my main thread, so how do I send a signal to this .await that it should stop sleeping and shut down instead? 回答1: Note: This answer currently links to the 1.x version of Tokio, but applies to Tokio 0