When one end of a TCP channel goes down, it sends a reset (RST) message to the other end. I want to get this at the application level.
In my code, I use the select() call to get input from potentially multiple sources, including a TCP connection. I saw that when select() shows that there is data ready to be read in the connection, then read() call returns 0 bytes that were read after the RST was sent over TCP. (I understand recv() works similarly to read() .)
Does read() return 0 bytes (after select() ) in a TCP connection only if the connection was reset? Does it ever return 0 bytes in any other cases?
I remember that some time ago I used a specific Ethernet device on the other end of the connection, and this end of Linux received 0 bytes after select() , but not for the reset connection, but rather through the middle some data streams. I confirmed in Wireshark that the received packet has 0 bytes of data. Is this a mistake or, as the question above, does it really have this behavior? I do not remember what device it was, as it was several years ago, but he used the Windows driver.
source share