I am using a Java Socket object in my client application. I need to know when the string on the server is broken, or if any event caused a socket leak.
I see two methods:
- catching SocketException when writing or reading from a socket, considering these exceptions, destroys the socket
- when catching these exceptions, checking the Socket.isClosed () method to see if it killed the socket
Does any of these methods guarantee that the socket will be dead and will not work again, even if the temporary problem on the line is resolved? Can we throw a Socket exception during a socket operation to suggest that the socket is dead?
Is there a better way to find out?
source
share