Expand description
tokio-icmp-echo is an asynchronous ICMP pinging library.
The repository is located at https://github.com/jcgruenhage/tokio-icmp-echo/.
§Usage example
Note, sending and receiving ICMP packets requires privileges.
use futures::{future, StreamExt};
#[tokio::main]
async fn main() {
let addr = std::env::args().nth(1).unwrap().parse().unwrap();
let pinger = tokio_icmp_echo::Pinger::new().await.unwrap();
let stream = pinger.chain(addr).stream();
stream.take(3).for_each(|mb_time| {
match mb_time {
Ok(Some(time)) => println!("time={:?}", time),
Ok(None) => println!("timeout"),
Err(err) => println!("error: {:?}", err)
}
future::ready(())
}).await;
}
Structs§
- Ping
Chain - Ping the same host several times.
- Ping
Chain Stream - Stream of sequential ping response times, iterates
None
if timed out. - Ping
Future - Represent a future that resolves into ping response time, resolves into
None
if timed out. - Pinger
- ICMP packets sender and receiver.