Hi, I'm using socket for chat application and I get SocketException unexpectedly. How this exception should ideally be handled? I'm currently simply reconnecting socket. How to make sure my socket is live on application level? I'm aware of method setKeepAlive
+2
A:
A SocketException
indicates an error on the network level, usually a TCP/IP error.
Handle this one of two ways: let your application decide if this is a constant issue (firewall, bad connection, etc...) and notify the user, or if this is temporary and can be restored, in which case you should try to reconnect to the socket.
setKeepAlive()
has nothing to do with restarting the connection. It only keeps sending keep-alive packets so the connection will not be terminated.
Yuval A
2010-03-25 10:24:35