Method isConnected()........please help!!

I am using the Socket class to make client-server connection:Can somebody please explain me the following:why after closing a connection with socket.close() return both methods socket.isConnected(),socket.isClosed() true? Why is the connection still
[299 byte] By [aimuellera] at [2007-10-2 10:50:53]
# 1

isConnected() returns true if the socket is connected or has been connected in the past.

I think isConnected() and isClosed() are rarely useful. It is better to write your application so you don't need them. Connect the socket to a server - then you know it is connected. When you are done communicating close it (usually in a finally clause). Then you know it is closed.

(Ok, perhaps sometimes servers with multiple clients, maybe asynchronous connect? But usually no.)

sjasjaa at 2007-7-13 3:09:17 > top of Java-index,Archived Forums,Socket Programming...
# 2
my application hold the connection to more than one server and get data every 10 sec. so it is better to hold the connection for long time and in this case it must check if the connection is still opened..
aimuellera at 2007-7-13 3:09:17 > top of Java-index,Archived Forums,Socket Programming...
# 3
The only way to do that is to try to use it. If you get a SocketException or EOFException the connection is closed.Socket.isConnected() only tells you about what you have done to your own Socket at this end, not about the state of the connection.
ejpa at 2007-7-13 3:09:17 > top of Java-index,Archived Forums,Socket Programming...