Skip to content

Commit

Permalink
protocols/dcutr/examples: Document delay hack
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Feb 1, 2022
1 parent 10046f2 commit 21ae03b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions protocols/dcutr/examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,24 @@ fn main() -> Result<(), Box<dyn Error>> {
)
.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;
}
}
}
});

Expand Down

0 comments on commit 21ae03b

Please sign in to comment.