03_network_reachability/03_network_reachability.rs
1use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
2
3use systemconfiguration::Reachability;
4
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let by_name = Reachability::with_name("localhost")?;
7 println!("localhost => {}", by_name.flags()?);
8
9 let by_address = Reachability::with_address(SocketAddr::V4(SocketAddrV4::new(
10 Ipv4Addr::LOCALHOST,
11 0,
12 )))?;
13 println!("127.0.0.1 => {}", by_address.flags()?);
14 Ok(())
15}