protohack

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

smoke.rs (478B)


      1 #[tokio::main]
      2 async fn main() -> std::io::Result<()> {
      3     println!("Smoketest server has started");
      4     let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await?;
      5     loop {
      6         let (mut socket, _) = listener.accept().await?;
      7         tokio::spawn(async move {
      8             let (mut rd, mut wr) = socket.split();
      9             if let Err(e) = tokio::io::copy(&mut rd, &mut wr).await {
     10                 println!("echo error: {}", e);
     11             }
     12         });
     13     }
     14 }