Add demo for responses
This commit is contained in:
parent
2aa154100c
commit
0a0b4218f9
1 changed files with 10 additions and 1 deletions
11
src/main.rs
11
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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue