use std::sync::mpsc;
use simple_mdns::{
sync_discovery::ServiceDiscovery, InstanceInformation, NetworkScope,
};
fn main() {
stderrlog::new().verbosity(2).init().ok();
let (tx, rx) = mpsc::channel();
let _discovery = ServiceDiscovery::new_with_scope(
InstanceInformation::new("my-instance".into())
.with_socket_address("127.0.0.1:8080".parse().unwrap()),
"_example._tcp.local",
60,
Some(tx),
NetworkScope::V4,
)
.expect("Failed to create ServiceDiscovery");
println!("Service discovery running — press Ctrl+C to exit");
for instance in rx {
println!("Discovered: {instance:?}");
}
}