Skip to main content

Socket connection checking

No replies
TimShiu
Offline
Joined: 2011-11-02
Points: 0

Hi All,

I would like to know if there is any socket connection checking can be performed to check if the server socket is disconnected unconditionally? (e.g. network failed, server is down, etc....)

I'm using java.net.Socket class to connect to server socket which will send bytes to the client while there is an event detected. The client program will be blocked at read() method to wait for input from server which may be sent at any time.
Unfortunately, the isConnected(), isInputShutdown() methods in Socket class has no changed and no exception will be thrown while the network is unplugged in server side. So I would like to ask if there is any mechanism to check if the server socket is still alive or is there any configuration can be set in order to receive socket exception if server socket is disconnected.

Thanks a lot.

Regards,
Tim.Shiu