[−][src]Crate async_io
Async I/O and timers.
To wait for the next I/O event, the reactor calls epoll on Linux/Android, kqueue on macOS/iOS/BSD, and wepoll on Windows.
Examples
Connect to example.com:80
, or time out after 10 seconds.
use async_io::{Async, Timer}; use futures_lite::{future::FutureExt, io}; use std::net::{TcpStream, ToSocketAddrs}; use std::time::Duration; let addr = "example.com:80".to_socket_addrs()?.next().unwrap(); let stream = Async::<TcpStream>::connect(addr).or(async { Timer::new(Duration::from_secs(10)).await; Err(io::ErrorKind::TimedOut.into()) }) .await?;
Modules
parking | Thread parking and unparking. |
Structs
Async | Async I/O. |
Timer | A timer that expires after a duration of time. |