Java Ganymed ssh 隧道...如何检查隧道是否仍然打开?
我有一个使用 Ganymed 的 LocalPortForwarder 类创建的 ssh 隧道。运行良好。问题是如何(以 Java 编程方式)检查隧道是否仍然打开且处于活动状态?
作为参考,这里是创建隧道的代码片段(为简洁起见,删除了错误检查):
Connection conn = new Connection(remoteHostName);
conn.connect();
boolean isAuthenticated = conn.authenticateWithPassword(username, password);
LocalPortForwarder lpf1
= conn.createLocalPortForwarder(newPort,
remoteHostName,
Integer.parseInt(remoteHostPort));
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));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检测任何 TCP 连接状态的唯一方法是尝试使用它。它不像 SNA 过去那样有“心跳”。
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.