From 920ed83bf4ea31802b8df73a3274c5010564d20e Mon Sep 17 00:00:00 2001 From: irving ou Date: Thu, 25 Jan 2024 12:19:08 -0500 Subject: [PATCH] update example update example --- examples/tcp_client.rs | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/examples/tcp_client.rs b/examples/tcp_client.rs index aa9d708..7637638 100644 --- a/examples/tcp_client.rs +++ b/examples/tcp_client.rs @@ -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(()) }