Open Douile opened 1 year ago
It's something that has been on my mind since starting the project, I didn't really had the time to look into how could this be done (as implementing functionality features such as protocols has priority) but it's coming for sure!
Current blocking things I have found:
As you've correctly identified, Tokio doesn't directly support setting timeout options on its asynchronous TCP or UDP streams. That's a design decision often found in asynchronous I/O libraries, because blocking operations (such as those with a timeout) conflict with the design goals of non-blocking, asynchronous I/O. Instead, timeouts are usually handled at a higher level. For example
use std::time::Duration;
use tokio::time::timeout;
use tokio::net::TcpStream;
let fut = TcpStream::connect("127.0.0.1:8080");
let tcp_stream = match timeout(Duration::from_secs(5), fut).await {
Ok(Ok(stream)) => stream,
Ok(Err(err)) => panic!("Failed to connect: {:?}", err),
Err(_) => panic!("Connection timed out"),
};
No where near top priority but it would be nice to have asynchronous network support preferably using tokio.