Detecting unexpectedly closed sockets

MisterX b.xavier at internet.lu
Sat Oct 16 04:02:20 EDT 2004


Toma,

> I work on a project where a bunch of clients connect to the 
> same server. The server needs to keep track of which users 
> are connected.
> The server adds the address of the client to a list when 
> connected, and removes it when disconnected. I can easily 
> track connections using the callback message of the accept 
> command, and disconnections using the socketClosed message. 
> However, how do I detect when a client unexpectedly loses its 
> connection?
> It seems that the sockets stay open even if one unplugs the 
> network cable for a while, and such.

Try to make a keep-alive heart beat. If the client doesn't send his
heartbeat each x minutes, consider it closed.

> Do the server need to "manually" send some kind of 
> reoccurring message to the client, and wait for an answer, to 
> verify the connection?
> My tests were done using Windows 2000 Pro.

Not to my knowledge but it's good practice to verify a connection
before sending a piece of info into the vast unknown cyberspace ;)

Cheers
Xavier



More information about the use-livecode mailing list