Struct simpdiscoverylib::BeaconListener [−][src]
pub struct BeaconListener { /* fields omitted */ }Expand description
BeaconListener listens for new Beacons on the specified port
Example of using BeaconSender with timeout
use simpdiscoverylib::BeaconListener; use std::time::Duration; let port = 9001; let listener = BeaconListener::new("_my_service._tcp.local".as_bytes()).expect("Could not create listener"); // Avoid blocking tests completely with no timeout, and set a very short one let beacon = listener.wait(Some(Duration::from_millis(1))); assert!(beacon.is_err());
Implementations
Create a new BeaconListener on port with an option filter to be applied to incoming
beacons. This binds to address “0.0.0.0:port”
Wait for a Beacon on the port specified in BeaconListener::new()
If timeout is None, then it will block forever waiting for a beacon matching the optional
filter (if supplied) in BeaconListener::new(). If no filter was supplied it will block
waiting for any beacon to be received.
If timeout is Some(Duration) then it will block for that duration on the reception of
each beacon. If the beacon does not match a supplied filter then it will loop (blocking
for duration each time until a matching beacon is found.