summaryrefslogtreecommitdiffstats
path: root/tokio/examples/print_each_packet.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio/examples/print_each_packet.rs')
-rw-r--r--tokio/examples/print_each_packet.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/tokio/examples/print_each_packet.rs b/tokio/examples/print_each_packet.rs
index b801ac8b..3729c3e9 100644
--- a/tokio/examples/print_each_packet.rs
+++ b/tokio/examples/print_each_packet.rs
@@ -54,28 +54,26 @@
#![warn(rust_2018_idioms)]
-use std::env;
-use std::net::SocketAddr;
-
use tokio;
use tokio::codec::{BytesCodec, Decoder};
use tokio::net::TcpListener;
use tokio::prelude::*;
+use std::env;
+
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Allow passing an address to listen on as the first argument of this
// program, but otherwise we'll just set up our TCP listener on
// 127.0.0.1:8080 for connections.
let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string());
- let addr = addr.parse::<SocketAddr>()?;
// Next up we create a TCP listener which will listen for incoming
// connections. This TCP listener is bound to the address we determined
// above and must be associated with an event loop, so we pass in a handle
// to our event loop. After the socket's created we inform that we're ready
// to go and start accepting connections.
- let mut listener = TcpListener::bind(&addr)?;
+ let mut listener = TcpListener::bind(&addr).await?;
println!("Listening on: {}", addr);
loop {