With Java sockets it's possible that the socket write method is successful even if the network is down.
When Java issues socket write the request is passed forward to the Windows socket send function. The documentation of send says thatTCP connection is open unless it's closed or terminated:
The successful completion of a send function does not indicate that the data was successfully delivered and received to the recipient. This function only indicates the data was successfully sent.and an older version also says
If data for which the peer protocol has buffer space cannot be successfully transmitted within a reasonable length of time, the connection is considered broken and subsequent calls will fail with the error code set to WSAETIMEDOUT.
For some operating systems "successfully delivered" just means that the data was passed into a buffer in the network stack, which will handle the transfer.
- application calls socket close
- application crashes and OS closes the socket
- OS closes the socket due to an event (e.g restart)
So if the network becomes disconnected the connection remains open if there's no data sent; there's no way to detect network hiccups just by listening to incoming connections.
TCP usually provides keep-alive messages to detect network failures.