diff options
Diffstat (limited to 'examples/udp_server.rs')
-rw-r--r-- | examples/udp_server.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/examples/udp_server.rs b/examples/udp_server.rs index febb662..95f8a83 100644 --- a/examples/udp_server.rs +++ b/examples/udp_server.rs @@ -1,14 +1,16 @@ // You can run this example from the root of the mio repo: -// cargo run --example udp_server --features="os-poll udp" +// cargo run --example udp_server --features="os-poll net" use log::warn; -use mio::net::UdpSocket; use mio::{Events, Interest, Poll, Token}; use std::io; // A token to allow us to identify which event is for the `UdpSocket`. const UDP_SOCKET: Token = Token(0); +#[cfg(not(target_os = "wasi"))] fn main() -> io::Result<()> { + use mio::net::UdpSocket; + env_logger::init(); // Create a poll instance. @@ -19,6 +21,7 @@ fn main() -> io::Result<()> { // Setup the UDP socket. let addr = "127.0.0.1:9000".parse().unwrap(); + let mut socket = UdpSocket::bind(addr)?; // Register our socket with the token defined above and an interest in being @@ -75,3 +78,8 @@ fn main() -> io::Result<()> { } } } + +#[cfg(target_os = "wasi")] +fn main() { + panic!("can't bind to an address with wasi") +} |