misc/mdns: Make MdnsService::new sync by using std::net::UdpSocket::bind (#1382)

* misc/mdns: Make MdnsService::new sync by using std::net::UdpSocket::bind

MdnsService uses an IP address to create a UDP socket. The address does
not need to be resolved. Therefore one can use std's UdpSocket::bind
instead of the async counterpart from async-std. As a result
MdnsService::new and MdnsService::silent don't need to be async.

* examples/mdns-passive-discovery: Don't await sync MdnsService::new

* misc/mdns/src/behaviour: Make Mdns::new sync

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
Max Inden
2020-01-15 13:43:09 +01:00
committed by Pierre Krieger
parent 680c467f7e
commit 991f5af993
5 changed files with 16 additions and 16 deletions

View File

@ -113,7 +113,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// Create a Kademlia behaviour.
let store = MemoryStore::new(local_peer_id.clone());
let kademlia = Kademlia::new(local_peer_id.clone(), store);
let mdns = task::block_on(Mdns::new())?;
let mdns = Mdns::new()?;
let behaviour = MyBehaviour { kademlia, mdns };
Swarm::new(transport, behaviour, local_peer_id)
};