use std::time::Duration;
#[tokio::main]
async fn main() {
let ips: Vec<String> = std::env::args().skip(1).collect();
if ips.is_empty() {
eprintln!("usage: cargo run --example probe_unicast -- <ip> [<ip>...]");
std::process::exit(2);
}
println!(
"probing {} target{} via unicast WS-Discovery (timeout 2s each)\n",
ips.len(),
if ips.len() == 1 { "" } else { "s" }
);
for ip_str in &ips {
let Ok(ip) = ip_str.parse::<std::net::IpAddr>() else {
println!("{ip_str:<16} ← INVALID IP");
continue;
};
let devices = oxvif::discovery::probe_unicast(ip, Duration::from_secs(2)).await;
if devices.is_empty() {
println!("{ip_str:<16} ← NO REPLY");
} else {
for d in &devices {
println!(
"{ip_str:<16} ← REACHED endpoint={} xaddrs={:?}",
d.endpoint, d.xaddrs
);
}
}
}
}