EldoS | Feel safer!

Software components for data protection, secure storage and transfer

When the remote socket is disconnected, TElSocket state (or Active property of socket-enabled components) indicates that connection is still present. Why?

TCP protocol was designed to be tolerant to temporary failures of the carrier. And if you don't transfer any data over established logical connection, TCP stack remains dormant and does nothing to detect the state of this connection.

If the remote system gracefully closes the socket (i.e. sends "goodbye" packets) AND the carrier is active, then TCP stack on your computer is notified about the socket being closed. If the remote system closes the connection forcefully (computer is powered off etc) or when the carrier fails on the way (say the satellite has fallen down or the shark has bitten the trans-Atlantic cable), local system knows nothing about connection state.

But in both cases Windows Sockets module doesn't have a way to notify the application about state change in other way than returning error on attempt to do something with the socket. So the best you can do is to send something over the socket. And if there's no connection available anymore, you will receive an error which will tell you that connection has died.

In some cases it is important to know current state of connection in order to notify the user or another software module. In this case the only option is to use so-called keep-alive packets in application-level protocol. Your application needs to send them periodically. For FTP this can be a request for current directory. SSH/SFTP offers keep-alive packets (they are supported in SecureBlackbox). In HTTP you can send OPTIONS request. Some other protocols have NOOP command or something similar. It is important that your code initiates sending of such requests as it is notified about the failure (and disconnection) as soon as possible in this case.

Remember to call Close() method of the corresponding SecureBlackbox in case of disconnection or when you are done using the component. This will let the component release resources and be ready for subsequent use.

Return to the list


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!