Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to check if a socket is still alive?

843790Jun 6 2006 — edited Jun 24 2006
Hi everybody,

I'm using a java.net.Socket and I'm unable to check wether or not the other site has closed the connection.
socket.isClosed() seems to only check if I have closed the connection, not the other one.
socket.isConnected() seems to check if there ever has been a connection.

I've searched for an answer, but I only found the suggestion to send dummy data and see if it throws an exception.

Has anybody got a better solution?

Thanks in advance!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2006
Added on Jun 6 2006
35 comments
1,313 views