added basic connection handler
Every connection the server recieves a new handle function is called
This commit is contained in:
parent
edcc024363
commit
f34b2c5cd7
10
src/main.rs
10
src/main.rs
|
|
@ -1,4 +1,6 @@
|
|||
use std::net::TcpListener;
|
||||
use std::net::TcpStream;
|
||||
use std::io::prelude::*;
|
||||
|
||||
fn main(){
|
||||
let listener = TcpListener::bind("127.0.0.1:6001").unwrap();
|
||||
|
|
@ -6,6 +8,12 @@ fn main(){
|
|||
for stream in listener.incoming(){
|
||||
let stream = stream.unwrap();
|
||||
|
||||
println!("Connection Established!");
|
||||
handle_connection(stream);
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_connection(mut stream: TcpStream){
|
||||
let mut buffer = [0; 512];
|
||||
stream.read(&mut buffer).unwrap();
|
||||
println!("Request: {}", String::from_utf8_lossy(&buffer[..]));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue