SecureBlackbox 16: Why doesn't the socket detect that the remote side was disconnected?

Note: This article applies only to SecureBlackbox Legacy. For future development please consider using the latest version.

TElSocket (or any other socket implementation) can't magically determine that the remote side has vanished or that the connection has been closed by the intermediate node (router, NAT, firewall, etc.). The socket can update its state after making an explicit attempt to send something and analyzing the result. In this case, the TCP stack tries to send a packet and after a certain timeout (or when an error is returned by a lower-level protocol) reports an error to the upper level. Only this operation lets one reliably detect socket disconnection. This is how TCP sockets work in any OS and this is by design (remember that ARPANet was designed as a decentralized network that must survive nuclear attack).

Many protocols include the so-called keep-alive feature, which usually includes sending an empty packet or no-operation command to the remote side in order to keep the socket alive and signal to NATs and firewalls that they should not close the connection.

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.