Java: clearing up confusion about what causes a connection to reset
There seems to be some confusion as well as conflicting statements on various SO answers: What is causing my java.net.SocketException: Connection reset? ... You can see here that the accepted answer says that the connection was closed by the other side. But this is not the case, closing the connection does not reset the connection. This is due to a "basic TCP / IP error".
What I want to know is if SocketException: Connection reset
means other than "TCP / IP error". What is actually causing this? As I doubt it has anything to do with closing a connection (since closing a connection is not a worthy exception flag, and reading from a closed connection is, but this is not a "basic TCP / IP error".
My hypothesis is this:
The reset connection was caused by a server failure to acknowledge the ACK packet (completely or just wrong according to TCP / IP). And that a SocketTimeoutException is only thrown when data is not generated read (since this is thrown during read after a certain duration and the read is waiting for data but not associated with ACK packets). In other words, read () will throw a SocketTimeoutException if it has not read a single DATA LAYER within the allotted time.
a source to share
From openjdk6 sources, I get a "Connection reset" message when an attempt to read data fails with ECONNRESET (Linux and Solaris) or WSAECONNRESET (Windows) error.
In my experience, the typical cause is that the side on the other end of the socket has closed the socket without first shutting down.
a source to share