1

I have an ssh tunnel created with Ganymed's LocalPortForwarder class. It's working fine. The question is how (programmatically in Java) do I check that the tunnel is still open and active?

For reference, here's the code snippet that creates the tunnel (error checking removed for brevity's sake):

Connection conn = new Connection(remoteHostName);

conn.connect();

boolean isAuthenticated = conn.authenticateWithPassword(username, password);

LocalPortForwarder lpf1
               = conn.createLocalPortForwarder(newPort,
                                               remoteHostName, 
                                               Integer.parseInt(remoteHostPort));
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304

1 Answers1

1

The only way to detect the state of any TCP connection is to try to use it. It doesn't have a 'heartbeat' like SNA used to.

user207421
  • 305,947
  • 44
  • 307
  • 483