Improve error handling for incoming TCP connections
This commit is contained in:
parent
8f8f152f5f
commit
f481dcfbf7
1 changed files with 6 additions and 4 deletions
10
src/main.rs
10
src/main.rs
|
@ -15,10 +15,12 @@ fn main() {
|
|||
let listener = TcpListener::bind("127.0.0.1:4762").unwrap();
|
||||
let pool = ThreadPool::new(4);
|
||||
for stream in listener.incoming() {
|
||||
let stream = stream.unwrap();
|
||||
pool.execute(|| {
|
||||
handle_connection(stream);
|
||||
});
|
||||
match stream {
|
||||
Ok(s) => pool.execute(|| {
|
||||
handle_connection(s);
|
||||
}),
|
||||
Err(e) => println!("invalid stream: {:?}\n", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue