commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Parkinson" <>
Subject commons-net: TelnetClient Question
Date Fri, 22 Aug 2003 18:45:33 GMT
Hi all, I haven't been able to find an answer to my question anywhere on
the web, so this is the next place I'm checking.  Hopefully someone has
run into this problem before.

What I'm looking for a is a way to determine when a TelnetClient
connection gets dropped.  I've tried using the isConnected() method
inherited from SocketClient, but it returns true when the connection has
definitely been dropped.  Here's a code snippet:

(this is from my thread that checks for available data in the

while (true)
    // Make sure we're still connected
    if (!client.isConnected())
      // Break out of the loop and handle the broken connection

    // Check for incoming data
    bytesAvailable = in.available();
    if (bytesAvailable > 0)
      // Grab the available data (the read()s don't block)
  catch ...

As I said earlier, the isConnected() method seems to always return true.
 Is there a different way to check the connection status, or am I using
the method improperly?

Any help will be *greatly* appreciated.
Thanks in advance. :)


View raw message