diff options
Diffstat (limited to 'examples/client.rs')
-rw-r--r-- | examples/client.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/examples/client.rs b/examples/client.rs index 88490aa..24966e7 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -52,7 +52,7 @@ fn main() { let url = url::Url::parse(&args.next().unwrap()).unwrap(); // Setup the event loop. - let poll = mio::Poll::new().unwrap(); + let mut poll = mio::Poll::new().unwrap(); let mut events = mio::Events::with_capacity(1024); // Resolve server address. @@ -68,16 +68,11 @@ fn main() { // Create the UDP socket backing the QUIC connection, and register it with // the event loop. - let socket = std::net::UdpSocket::bind(bind_addr).unwrap(); - - let socket = mio::net::UdpSocket::from_socket(socket).unwrap(); - poll.register( - &socket, - mio::Token(0), - mio::Ready::readable(), - mio::PollOpt::edge(), - ) - .unwrap(); + let mut socket = + mio::net::UdpSocket::bind(bind_addr.parse().unwrap()).unwrap(); + poll.registry() + .register(&mut socket, mio::Token(0), mio::Interest::READABLE) + .unwrap(); // Create the configuration for the QUIC connection. let mut config = quiche::Config::new(quiche::PROTOCOL_VERSION).unwrap(); @@ -120,7 +115,7 @@ fn main() { let (write, send_info) = conn.send(&mut out).expect("initial send failed"); - while let Err(e) = socket.send_to(&out[..write], &send_info.to) { + while let Err(e) = socket.send_to(&out[..write], send_info.to) { if e.kind() == std::io::ErrorKind::WouldBlock { debug!("send() would block"); continue; @@ -216,7 +211,7 @@ fn main() { ); print!("{}", unsafe { - std::str::from_utf8_unchecked(&stream_buf) + std::str::from_utf8_unchecked(stream_buf) }); // The server reported that it has no more data to send, which @@ -251,7 +246,7 @@ fn main() { }, }; - if let Err(e) = socket.send_to(&out[..write], &send_info.to) { + if let Err(e) = socket.send_to(&out[..write], send_info.to) { if e.kind() == std::io::ErrorKind::WouldBlock { debug!("send() would block"); break; |