Thank you very much for your reply.
I tried to read with 0-sized buffer as follows.
use std::io::Read;
fn main() -> std::io::Result<()> {
let l = std::net::TcpListener::bind("127.0.0.1:3000")?;
loop {
let (mut stream, _) = l.accept()?;
println!("new stream: {:?}", stream);
loop {
let mut buf = [];
let r = stream.read(&mut buf);
println!("read result: {:?}", r);
std::thread::sleep(std::time::Duration::from_secs(1));
}
}
}
But, .read() always returns Ok(()) after Ctrl+C.
