> When I close a socket from a side of it with
>
[quoted text clipped - 15 lines]
>
> Does someone ever deal with that stuff?
The methods isClosed() etc only tell you the state of the Socket
*object* itself, not the state of the underlying socket, i.e. they
tell you whether you've called the corresponding close() method.
To determine whether a socket connection is still active, you must
attempt to read from it or write to it. Depending on what mechanism
you use, you may get an exception or simply a value indicating EOF.
Read the appropriate documentation.
/gordon.

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
oziris - 17 Jan 2006 09:34 GMT
Indeed when the socket is closed the read() method returns -1.
But in my application context this just does mean there is nothing to
read, i.e. I can't conclude my socket has been closed by the other side
with that returned code :-(
Another idea?
Thanks.
-o--
Gordon Beaton - 17 Jan 2006 10:04 GMT
> Indeed when the socket is closed the read() method returns -1.
>
> But in my application context this just does mean there is nothing
> to read, i.e. I can't conclude my socket has been closed by the
> other side with that returned code :-(
If InputStream.read() returns -1, it means you have reached EOF. It
does not mean there is nothing to read at the moment, it means you
will never be able to read data from the socket again.
Exactly what class and method are you using to read from your socket?
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
oziris - 17 Jan 2006 10:14 GMT
I'm using the method read(char[], int, int) on an object BufferedReader
BufferedReader m_inputStream =
new BufferedReader(
new InputStreamReader(socket.getInputStream()));
-o--
Gordon Beaton - 17 Jan 2006 10:25 GMT
> I'm using the method read(char[], int, int) on an object BufferedReader
From the API documentation for BufferedReader.read(char[], int, int):
Returns: The number of characters read, or -1 if the end of the
stream has been reached.
With emphasis: the *end* of the stream. There will be no more data on
this stream, ever.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e