fn main() { let server_sock = lx::socket(i32::from(lx::AF_INET), lx::SOCK_STREAM, 0).unwrap(); lx::bind(&server_sock, &lx::SockAddrIn::new([0, 0, 0, 0], 8080)).unwrap(); lx::listen(&server_sock, 10).unwrap(); let future = async move { loop { let client_fd = azur::accept(&server_sock, lx::SOCK_CLOEXEC | lx::SOCK_NONBLOCK) .await .unwrap(); azur::spawn(async move { let mut buf = Vec::with_capacity(1024); let mut ret: Result<(), lx::Error>; loop { (ret, buf) = azur::read(&client_fd, buf, 0).await; if let Err(err) = ret { panic!("read failed: {err}"); } if buf.is_empty() { break; } (ret, buf) = azur::write_exact(&client_fd, buf, 0).await; if let Err(err) = ret { panic!("write failed: {err}"); } } }); } }; azur::spawn(future); azur::run().unwrap(); }