Page 1 of 1

TCP Testing connection

Posted: Tue Nov 17, 2009 4:31 am
by noob
Hello,

I have a problem where theres a server running that will do a TCP poll every 5 minutes or so and I am experiencing that the connection will be lost. To deal with this I am currently having a 15 min timeout and then running the accept command again. Is there a better way to test that there is still a connection. My polling server is not detecting the comm loss and it just returns read errors - timeout.

Thanks

Re: TCP Testing connection

Posted: Tue Nov 17, 2009 5:40 am
by Chris Ruff
I am thinking that the proper way to do this is to open the socket connection, do the work, drop the socket connection

every 5 minutes you perform this task and don't expect TCP connections to remain open all day. This is the way browsers work, no connections hang open.

If you want the socket connection to remain open then you will need to implement a keepalive handshake so that the server knows it has lost the connection and can reset the listener socket to listen and accept incoming clients if the handshake disapppears.


Chris