examples: use mio-v0.8
diff --git a/quiche/Cargo.toml b/quiche/Cargo.toml index a99ce44..bdf7a9c 100644 --- a/quiche/Cargo.toml +++ b/quiche/Cargo.toml
@@ -66,7 +66,7 @@ winapi = { version = "0.3", features = ["wincrypt"] } [dev-dependencies] -mio = "0.6" +mio = { version = "0.8", features = ["net", "os-poll"] } url = "1" [lib]
diff --git a/quiche/examples/client.rs b/quiche/examples/client.rs index 7f97b6d..0683b15 100644 --- a/quiche/examples/client.rs +++ b/quiche/examples/client.rs
@@ -52,7 +52,7 @@ 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. @@ -69,15 +69,12 @@ // Create the UDP socket backing the QUIC connection, and register it with // the event loop. let socket = std::net::UdpSocket::bind(bind_addr).unwrap(); + socket.set_nonblocking(true).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::from_std(socket); + 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 +117,7 @@ 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; @@ -251,7 +248,7 @@ }, }; - 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;
diff --git a/quiche/examples/http3-client.rs b/quiche/examples/http3-client.rs index 7085481..062675b 100644 --- a/quiche/examples/http3-client.rs +++ b/quiche/examples/http3-client.rs
@@ -52,7 +52,7 @@ 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. @@ -69,15 +69,12 @@ // Create the UDP socket backing the QUIC connection, and register it with // the event loop. let socket = std::net::UdpSocket::bind(bind_addr).unwrap(); + socket.set_nonblocking(true).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::from_std(socket); + 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(); @@ -121,7 +118,7 @@ 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; @@ -316,7 +313,7 @@ }, }; - 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;
diff --git a/quiche/examples/http3-server.rs b/quiche/examples/http3-server.rs index 777ab99..526706d 100644 --- a/quiche/examples/http3-server.rs +++ b/quiche/examples/http3-server.rs
@@ -70,20 +70,17 @@ } // 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); // Create the UDP listening socket, and register it with the event loop. let socket = net::UdpSocket::bind("127.0.0.1:4433").unwrap(); + socket.set_nonblocking(true).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::from_std(socket); + poll.registry() + .register(&mut socket, mio::Token(0), mio::Interest::READABLE) + .unwrap(); // Create the configuration for the QUIC connections. let mut config = quiche::Config::new(quiche::PROTOCOL_VERSION).unwrap(); @@ -198,7 +195,7 @@ let out = &out[..len]; - if let Err(e) = socket.send_to(out, &from) { + if let Err(e) = socket.send_to(out, from) { if e.kind() == std::io::ErrorKind::WouldBlock { debug!("send() would block"); break; @@ -235,7 +232,7 @@ let out = &out[..len]; - if let Err(e) = socket.send_to(out, &from) { + if let Err(e) = socket.send_to(out, from) { if e.kind() == std::io::ErrorKind::WouldBlock { debug!("send() would block"); break; @@ -405,7 +402,7 @@ }, }; - 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;
diff --git a/quiche/examples/server.rs b/quiche/examples/server.rs index a632bbc..bed15ac 100644 --- a/quiche/examples/server.rs +++ b/quiche/examples/server.rs
@@ -64,20 +64,17 @@ } // 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); // Create the UDP listening socket, and register it with the event loop. let socket = net::UdpSocket::bind("127.0.0.1:4433").unwrap(); + socket.set_nonblocking(true).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::from_std(socket); + poll.registry() + .register(&mut socket, mio::Token(0), mio::Interest::READABLE) + .unwrap(); // Create the configuration for the QUIC connections. let mut config = quiche::Config::new(quiche::PROTOCOL_VERSION).unwrap(); @@ -192,7 +189,7 @@ let out = &out[..len]; - if let Err(e) = socket.send_to(out, &from) { + if let Err(e) = socket.send_to(out, from) { if e.kind() == std::io::ErrorKind::WouldBlock { debug!("send() would block"); break; @@ -229,7 +226,7 @@ let out = &out[..len]; - if let Err(e) = socket.send_to(out, &from) { + if let Err(e) = socket.send_to(out, from) { if e.kind() == std::io::ErrorKind::WouldBlock { debug!("send() would block"); break; @@ -348,7 +345,7 @@ }, }; - 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;