Function surge_ping::ping
source · pub async fn ping(
host: IpAddr,
payload: &[u8]
) -> 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()?, &[1,2,3,4,5,6,7,8]).await {
Ok((_packet, duration)) => println!("duration: {:.2?}", duration),
Err(e) => println!("{:?}", e),
};
§Errors
This function fails if:
- socket create failed