public SetHandler ( IDataHandler handler ) : void | ||
handler | IDataHandler | handler |
Результат | void |
/** * open a new SSH connection via the .NET socket */ public static SSHConnection Connect(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, Socket underlying_socket) { if (param.UserName == null) throw new InvalidOperationException("UserName property is not set"); if (param.AuthenticationType != AuthenticationType.KeyboardInteractive && param.Password == null) throw new InvalidOperationException("Password property is not set"); PlainSocket s = new PlainSocket(underlying_socket, null); VersionExchangeHandler pnh = new VersionExchangeHandler(param, s); s.SetHandler(pnh); s.RepeatAsyncRead(); return ConnectMain(param, receiver, pnh, s); }
/** * open a new SSH connection via the .NET socket */ public static SSHConnection Connect(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, Socket underlying_socket) { if (param.UserName == null) throw new InvalidOperationException("UserName property is not set"); if (param.AuthenticationType != AuthenticationType.KeyboardInteractive && param.Password == null) throw new InvalidOperationException("Password property is not set"); PlainSocket s = new PlainSocket(underlying_socket, null); try { SSHProtocolVersionReceiver protoVerReceiver = new SSHProtocolVersionReceiver(); protoVerReceiver.Receive(s, 5000); protoVerReceiver.Verify(param.Protocol); SSHConnection con; if (param.Protocol == SSHProtocol.SSH1) con = new SSH1Connection(param, s, receiver, protoVerReceiver.ServerVersion, SSHUtil.ClientVersionString(param.Protocol)); else con = new SSH2Connection(param, s, receiver, protoVerReceiver.ServerVersion, SSHUtil.ClientVersionString(param.Protocol)); s.SetHandler(con.Packetizer); s.RepeatAsyncRead(); con.SendMyVersion(param); if (con.Connect() == AuthenticationResult.Failure) { s.Close(); return null; } return con; } catch (Exception) { s.Close(); throw; } }