diff --git a/src/main.rs b/src/main.rs index 25d9eb7..fcd0726 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,7 +61,7 @@ fn create_socket() -> PathBuf { temp_dir } -fn handle_client(stream: UnixStream) { +fn handle_client(mut stream: UnixStream) { const TIMEOUT: Duration = Duration::from_secs(3); let reader = BufReader::new(stream.try_clone().unwrap()); @@ -96,6 +96,9 @@ fn handle_client(stream: UnixStream) { for line in lines { dbg!(line.unwrap()); + + // Panics if the socket dies mid-loop + writeln!(stream, "REPLY").unwrap(); } println!("Closed - killing thread"); @@ -104,6 +107,8 @@ fn handle_client(stream: UnixStream) { fn client(path: String) { let mut stream = UnixStream::connect(path).unwrap(); + let reader = BufReader::new(stream.try_clone().unwrap()); + thread::sleep(Duration::from_secs(2)); writeln!(stream, "handshake").unwrap(); @@ -114,6 +119,10 @@ fn client(path: String) { writeln!(stream, "Hello world").unwrap(); + let resp = reader.lines().next(); + + dbg!(resp); + thread::sleep(Duration::from_secs(2)); }