Crate simpdiscoverylib[][src]

Expand description

This is the library part of the simpdiscovery crate for simple UDP datagram-based discovery of services on a Local Area Network

Example Usage in a combined BeaconSender and BeaconListener

use simpdiscoverylib::{BeaconSender, BeaconListener};
use std::time::Duration;

let port = 9001;
let my_service_name = "_my_service._tcp.local".as_bytes();
if let Ok(beacon) = BeaconSender::new(port, my_service_name) {
    std::thread::spawn(move || {
        let _ = beacon.send_loop(Duration::from_secs(1));
    });
}

let listener = BeaconListener::new(my_service_name).expect("Could not create listener");
let beacon = listener.wait(None).expect("Failed to receive beacon");
assert_eq!(beacon.service_name, my_service_name, "Service name received in beacon doesn't match the one expected");
assert_eq!(beacon.service_port, port);

Structs

Beacon contains information about the beacon that was received by a BeaconListener

BeaconListener listens for new Beacons on the specified port

BeaconSender is used to send UDP Datagram beacons to the Broadcast IP address on the LAN