From 21ae03bbe9a30bc4ce567511f81343d0af54043c Mon Sep 17 00:00:00 2001 From: Max Inden Date: Tue, 1 Feb 2022 20:51:51 +0100 Subject: [PATCH] protocols/dcutr/examples: Document delay hack --- protocols/dcutr/examples/client.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/protocols/dcutr/examples/client.rs b/protocols/dcutr/examples/client.rs index 4e9da81f55f..af848817445 100644 --- a/protocols/dcutr/examples/client.rs +++ b/protocols/dcutr/examples/client.rs @@ -165,23 +165,24 @@ fn main() -> Result<(), Box> { ) .unwrap(); - // Wait to listen on localhost. + // Wait to listen on all interfaces. block_on(async { let mut delay = futures_timer::Delay::new(std::time::Duration::from_secs(1)).fuse(); loop { futures::select! { - event = swarm.next() => { - match event.unwrap() { - SwarmEvent::NewListenAddr { address, .. } => { - info!("Listening on {:?}", address); - } - event => panic!("{:?}", event), - } - } - _ = delay => { - break; - } + event = swarm.next() => { + match event.unwrap() { + SwarmEvent::NewListenAddr { address, .. } => { + info!("Listening on {:?}", address); } + event => panic!("{:?}", event), + } + } + _ = delay => { + // Likely listening on all interfaces now, thus continuing by breaking the loop. + break; + } + } } });