From b560fca37f6571c18b12d6fff4b3e86e549db6be Mon Sep 17 00:00:00 2001 From: Adam Carpenter <53hornet@gmail.com> Date: Tue, 26 Mar 2019 15:50:24 -0400 Subject: Added graceful termination. Book done for real this time XD --- hello_server/src/bin/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'hello_server/src/bin') diff --git a/hello_server/src/bin/main.rs b/hello_server/src/bin/main.rs index 522777a..bcf1e46 100644 --- a/hello_server/src/bin/main.rs +++ b/hello_server/src/bin/main.rs @@ -10,7 +10,7 @@ fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let pool = ThreadPool::new(4).unwrap(); - for stream in listener.incoming() { + for stream in listener.incoming().take(2) { let stream = stream.unwrap(); pool.execute(|| { @@ -18,6 +18,8 @@ fn main() { }); } + println!("shutting down..."); + } fn handle_connection(mut stream: TcpStream) { -- cgit v1.2.3