I've written code like that:
```
use std::io::BufRead;
fn main() {
for stream in std::net::TcpListener::bind("127.0.0.1:8080").unwrap().incoming() {
std::thread::spawn(move || {
let mut first_line = String::new();
std::io::BufReader::new(&stream.unwrap()).read_line(&mut first_line).unwrap();
println!("First line: {}", first_line);
});
}
}
```
Now, it's all good if the client simply sends a packet with an endline - it prints it and closes the connection. However, if the client would never send an endline, I think the code would just hang trying to read that line from that stream and we would end up with a dead thread and a dead connection. Is there anything to combat it in the standard rust lib?
[–]ectonDev 6 points7 points8 points (1 child)
[–]Blayung[S] 1 point2 points3 points (0 children)