(Note - this is not a duplicate - the question explicitly mentions not modifying the InputStream.)
I want to be able to check if the remote end of the connection is closed without modifying the socket's InputStream. I can't call read() on the InputStream because that will read data, and other portions of the code are going to be reading from the socket and expecting that data.
I've also tried calling read() with a 0-length buffer, but that doesn't work either (returns 0 instead of -1, even if the connection is broken).
(I guess what I want to do is call read() and if the result is not -1, "push" the byte back into the InputStream.)
Is there any way to get around this?
Thanks!