I am using TTCPBlockSocket
for a TCP/IP Application . The problem is that I can't determine when the connection is lost.
GetLastError
returns 0
Read
returns 0
But I encounter these values eaven if the application is connected so I can get it how can I be notified when the TCP/IP connection is lost.
Thanks
I would say, you can use the
CanRead
method, passing 0 to itsTimeout
parameter. This function internally performsselect
function for the socket and returns False when an error occurs. It should be enough to use just this method since theselect
function returnsSOCKET_ERROR
if you lose the connection, and it causes theCanRead
method return False as a result. So I think, it's enough to check if the socket connection is alive this way: