- Two computers are connected by socket connection. If the server/client closes the connection
from their end(i.e closes the
InputStream
,OutputStream
andSocket
) then how can I inform the other end about the disconnection? There is one way I know of - trying to read from theInputStream
, which throws anIOException
if connection is closed, but is there any other way to detect this? - Another question, I looked the problem up on the internet and saw
inputStream.available()
does not solve this problem. Why is that?
Additional Information : I'm asking for another way because my project becomes tough to handle if I have to try to read from the
InputStrem
to detect a disconnection.