Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
update example
  • Loading branch information
irvingoujAtDevolution committed Jan 25, 2024
1 parent 7d587d8 commit 920ed83
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions examples/tcp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,23 @@ fn main() -> io::Result<()> {
}
let addr = net::SocketAddr::new(net::Ipv4Addr::LOCALHOST.into(), 8080);
socket.set_nonblocking(true)?;
let res = socket.connect(&addr.into());
let _ = socket.connect(&addr.into());

let mut events = polling::Events::new();
// while let Err(ref e) = res {
// if e.kind() != io::ErrorKind::WouldBlock {
// return Err(io::Error::new(e.kind(), e.to_string()));
// }

events.clear();
poller.wait(&mut events, None)?;
events.clear();
poller.wait(&mut events, None)?;

let event = events.iter().next();
if event.is_none() {
println!("no event");
// break;
}
let event = events.iter().next();
let Some(event) = event else {
println!("no event");
return Ok(());
};

let event = event.unwrap();
println!("event: {:?}", event);
if event.is_connect_failed() {
println!("connect failed");
// break;
}
// }
println!("event: {:?}", event);
if event.is_connect_failed() {
println!("connect failed");
}

Ok(())
}

0 comments on commit 920ed83

Please sign in to comment.