TCP Testing connection

Discussion to talk about software related topics only.
Post Reply
noob
Posts: 5
Joined: Sat Sep 19, 2009 5:28 am

TCP Testing connection

Post 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
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: TCP Testing connection

Post 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
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
Post Reply