use std::thread; use std::os::unix::net::{UnixStream, UnixListener}; use std::println; use std::io::prelude::*; use std::time::Duration; use std::io::{BufWriter, BufReader, Read};
fnhandle_client(stream: UnixStream) { letmut read_stream = BufReader::new(&stream); letmut res = String::new(); // for line in read_stream.lines() { // println!("Server: {}", line.unwrap()); // } // read_lines is not recommended: as a new line ch is required. read_stream.read_to_string(&mut res).unwrap(); println!("Server: {res:?}");
// each request for one connection (Otherwise, the streaming is recognized as one transfer process) letmut soc = UnixStream::connect("/tmp/dbs.socks").unwrap(); soc.write_all(b"Hello! dsa\n").unwrap(); // let mut reader = BufReader::new(&soc); println!("send"); thread::sleep(Duration::from_millis(200)); }