本文整理汇总了C#中Renci.SshNet.SshClient.SendKeepAlive方法的典型用法代码示例。如果您正苦于以下问题:C# SshClient.SendKeepAlive方法的具体用法?C# SshClient.SendKeepAlive怎么用?C# SshClient.SendKeepAlive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renci.SshNet.SshClient
的用法示例。
在下文中一共展示了SshClient.SendKeepAlive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildTunnel
/// <summary>
/// Connect to SSH-Server and open TCP tunnel.
/// </summary>
/// <returns>Returns true on success, else false.</returns>
private bool BuildTunnel()
{
try
{
client = new SshClient(config.SupportHost,
config.SupportPort,
textBoxUsername.Text,
textBoxPassword.Text);
client.ErrorOccurred += new EventHandler<Renci.SshNet.Common.ExceptionEventArgs>(client_ErrorOccurred);
client.KeepAliveInterval = new System.TimeSpan(0, 0, 10);
client.Connect();
client.SendKeepAlive();
var port = new ForwardedPortRemote(IPAddress.Loopback,
config.FwdRemotePort, IPAddress.Loopback, config.FwdLocalPort);
port.Exception += new EventHandler<Renci.SshNet.Common.ExceptionEventArgs>(port_Exception);
port.RequestReceived += new EventHandler<Renci.SshNet.Common.PortForwardEventArgs>(port_RequestReceived);
client.AddForwardedPort(port);
port.Start();
}
catch (System.Exception ex)
{
Log.WriteLine("BuildTunnel() general exception: {0}", ex.Message);
if (client.IsConnected)
{
client.Disconnect();
}
MessageBox.Show(GetCaption("serverLoginError"), GetCaption("loginFailed"),
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
return sessionActive = true;
}