Page 1 of 1

Testing server sockets

Posted: Sun Aug 08, 2010 12:11 pm
by skindoc4
I wonder if someone on the forum can point me in the right direction.

I have written a client server database application using sockets. I have found that for one reason or another, a client connection may close but the socket remains open on the server side. Attempts by the client to re-establish a connection are then seemingly blocked.

Is there a way for the server to test its open sockets to see if they are still valid and to close them if there is no active client connection?

Alex

Re: Testing server sockets

Posted: Sun Aug 08, 2010 2:17 pm
by bangkok
I think it would be better to invert the logic, AKA to close the socket on the client side after each query sent to / answer received from the server.

You'll find a example with a duo of stacks here :
http://forums.runrev.com/phpBB2/downloa ... php?id=128

Re: Testing server sockets

Posted: Mon Aug 09, 2010 1:29 am
by skindoc4
Yes I do that routinely but sometimes the message from the client to the server is lost so the socket closes on the client side but remains open on the server side. There is then no way that I can work out to get the client reconnected to the server using the same port. Another option might be to use a different port using a new connection to kill the original server socket - might try this but I was hoping for something more elegant from the server side.

alex