6 releases

Uses old Rust 2015

0.3.0 Sep 23, 2019
0.2.1 Aug 11, 2019
0.2.0 Jun 17, 2018
0.1.2 Mar 18, 2018
0.1.0 Dec 6, 2017

#14 in #icmp

Download history 39/week @ 2024-04-01 13/week @ 2024-04-08 8/week @ 2024-04-15 15/week @ 2024-04-22 7/week @ 2024-04-29 7/week @ 2024-05-06 14/week @ 2024-05-13 10/week @ 2024-05-20 17/week @ 2024-05-27 13/week @ 2024-06-03 13/week @ 2024-06-10 9/week @ 2024-06-17 22/week @ 2024-06-24 20/week @ 2024-07-01 15/week @ 2024-07-15

59 downloads per month

MIT/Apache

29KB
764 lines

tokio-ping

Build Status Latest Version docs

tokio-ping is an asynchronous ICMP pinging library.

Usage example

Note, sending and receiving ICMP packets requires privileges.

extern crate futures;
extern crate tokio;

extern crate tokio_ping;

use futures::{Future, Stream};

fn main() {
    let addr = std::env::args().nth(1).unwrap().parse().unwrap();

    let pinger = tokio_ping::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

~3.5MB
~60K SLoC