Crates.io | tokio-icmp-echo |
lib.rs | tokio-icmp-echo |
version | 0.4.1 |
source | src |
created_at | 2021-04-27 18:47:59.098198 |
updated_at | 2022-03-17 15:00:55.620149 |
description | Asynchronous ICMP pinging library |
homepage | |
repository | https://github.com/jcgruenhage/tokio-icmp-echo |
max_upload_size | |
id | 390301 |
size | 55,431 |
tokio-icmp-echo is an asynchronous ICMP pinging library. It was originally written by Fedor Gogolev, a.k.a. knsd, and distributed under the name tokio-ping. This here is a fork that includes mostly maintenance work, to make sure it works in the current state of the async rust ecosystem.
Note, sending and receiving ICMP packets requires privileges.
extern crate futures;
extern crate tokio;
extern crate tokio_icmp_echo;
use futures::{Future, Stream};
fn main() {
let addr = std::env::args().nth(1).unwrap().parse().unwrap();
let pinger = tokio_icmp_echo::Pinger::new();
let stream = pinger.and_then(move |pinger| Ok(pinger.chain(addr).stream()));
let future = stream.and_then(|stream| {
stream.take(3).for_each(|mb_time| {
match mb_time {
Some(time) => println!("time={}", time),
None => println!("timeout"),
}
Ok(())
})
});
tokio::run(future.map_err(|err| {
eprintln!("Error: {}", err)
}))
}
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.