[英]Java Ganymed ssh tunnelling… How to check that a tunnel is still open?
I have an ssh tunnel created with Ganymed's LocalPortForwarder class. 我有一个用Ganymed的LocalPortForwarder类创建的ssh隧道。 It's working fine.
一切正常。 The question is how (programmatically in Java) do I check that the tunnel is still open and active?
问题是如何(以Java编程方式)检查隧道是否仍处于打开状态并处于活动状态?
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));
The only way to detect the state of any TCP connection is to try to use it. 检测任何TCP连接状态的唯一方法是尝试使用它。 It doesn't have a 'heartbeat' like SNA used to.
它没有像SNA那样的“心跳”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.