diff --git a/src/main.rs b/src/main.rs index 4c0a7f4..301dfd0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use log::info; use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; +use std::thread; static GET: &'static [u8] = b"GET / HTTP/1.1\r\n"; @@ -8,7 +9,10 @@ fn main() -> std::io::Result<()> { env_logger::init(); let listener = TcpListener::bind("127.0.0.1:7878")?; for stream in listener.incoming() { - handle_connection(stream?)?; + let stream = stream?; + thread::spawn(|| { + handle_connection(stream).unwrap(); + }); } Ok(()) }