]> git.lizzy.rs Git - connect-rs.git/blobdiff - examples/tcp-echo-server/src/main.rs
make async-oriented, remove block_on
[connect-rs.git] / examples / tcp-echo-server / src / main.rs
index cc5b5d7d3fa9e2a4f250fe649d18b6e24330ce1d..1c6f588ca710edd3f8904f653145a9f9210a8336 100644 (file)
@@ -23,11 +23,11 @@ async fn main() -> anyhow::Result<()> {
     };
 
     // create a server
-    let mut server = TcpServer::new(ip_address)?;
+    let server = TcpServer::new(ip_address).await?;
 
     // handle server connections
     // wait for a connection to come in and be accepted
-    while let Some(mut conn) = server.next().await {
+    while let Ok(mut conn) = server.accept().await {
         info!("Handling connection from {}", conn.peer_addr());
 
         task::spawn(async move {