How to know when std::net::TcpStream ends

How do I know when the client ends the TcpStream? I don't get an error when trying to read from a TcpStream which I've closed on the client side.
s is a TcpStream

        let mut recv = [0; 1024];
        match recv) {
            Ok(b) => { println!("read") },
            Err(e) => {

Take a look at the documentation for Read::read(). The stream being closed is signaled by read() returning Ok(0).

1 Like

recv length is zero
just check! when recv data zero is disconnected.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.