#11 make it multi threaded

This commit is contained in:
Shautvast 2026-02-09 19:52:44 +01:00
parent 9401dcc598
commit 98fa3207bb

View file

@ -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(())
}