#11 make it multi threaded
This commit is contained in:
parent
9401dcc598
commit
98fa3207bb
1 changed files with 5 additions and 1 deletions
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue