2 releases

0.4.1 Mar 17, 2022
0.4.0 Apr 27, 2021

#17 in #icmp

Download history 63/week @ 2024-07-26 137/week @ 2024-08-02 324/week @ 2024-08-09 256/week @ 2024-08-16 481/week @ 2024-08-23 487/week @ 2024-08-30 576/week @ 2024-09-06 783/week @ 2024-09-13 618/week @ 2024-09-20 498/week @ 2024-09-27 255/week @ 2024-10-04 65/week @ 2024-10-11 168/week @ 2024-10-18 94/week @ 2024-10-25 105/week @ 2024-11-01 73/week @ 2024-11-08

449 downloads per month
Used in peshming

MIT/Apache

28KB
692 lines

tokio-icmp-echo

Latest Version docs

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.

Usage example

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)
    }))
}

License

This project is licensed under either of

at your option.

Contribution

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.

Dependencies

~4–13MB
~151K SLoC