pub async fn ping(host: IpAddr) -> Result<(IcmpPacket, Duration), SurgeError>
Expand description

Shortcut method to ping address. NOTE: This function creates a new internal Client on each call, and so should not be used if making many target. Create a Client instead.

Examples

match surge_ping::ping("127.0.0.1".parse()?).await {
    Ok((_packet, duration)) => println!("duration: {:.2?}", duration),
    Err(e) => println!("{:?}", e),
};

Errors

This function fails if:

  • socket create failed