tags:

views:

99

answers:

1

Hi I have created a socket server and client program. My socket server is running on different computer and in my computer socket client is there. It works fine But the problem is that if there is no internet connection from the beginning in client computer then during I create socket connection I gets error.

only once i will create socket connection and then for infinite I am trying to send data to server and server receives the data perfectly. but in between these if at any point of time I disconnect client internet then also I am unable to get any exception so that I can know that my internet connection is disconnected or my socket connection is not present or my socket connection became null . So how to detect the internet connection failure at this point of time...

Thanks Sunil Kumar Sahoo

A: 

You should use the setKeepAlive(true) method. Then you should configure your keep-alive timeout per your OS. I remember that Windows had a very large keep-alive timeout so merely setting the keep-alive option would do no good.

Another option is to implement the keep-alive functionary at the application level yourself, instead of relying on the TCP layer to do this checking.

Sergio Oliveira Jr.