Last active
July 6, 2022 09:20
-
-
Save oscartbeaumont/0a069836041e257b5649f26b7b028ba7 to your computer and use it in GitHub Desktop.
mdns-sd multiple ip's not working bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use mdns_sd::{ServiceDaemon, ServiceEvent, ServiceInfo}; | |
fn main() { | |
let mdns = ServiceDaemon::new().expect("Failed to create daemon"); | |
let service_info = ServiceInfo::new( | |
&"_demo._udp.local.", | |
&"a", | |
"192.168.1.111.local.", | |
&vec!["1.1.1.1", "2.2.2.2"][..], // "192.168.1.111", // TODO: Handle multiple addrs | |
42069, | |
None, | |
) | |
.expect("valid service info"); | |
mdns.register(service_info) | |
.expect("Failed to register mDNS service"); | |
let receiver = mdns.browse(&"_demo._udp.local.").expect("Failed to browse"); | |
while let Ok(event) = receiver.recv() { | |
match event { | |
ServiceEvent::ServiceResolved(info) => { | |
println!("{:?}", info); | |
} | |
_ => {} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment