Sehraf.RSRPC.RSSSHConnector.Connect C# (CSharp) Method

Connect() public method

public Connect ( ) : bool
return bool
        public bool Connect()
        {
            System.Diagnostics.Debug.WriteLineIf(DEBUG, "ssh: connecting ....");
            try
            {
                ConnectionInfo info = new PasswordConnectionInfo(_host,_port, _user, _pw);
                _client = new SshClient(info);
                _client.ErrorOccurred += SSHError;
                _client.Connect();
                _stream = _client.CreateShellStream("xterm", 80, 24, 800, 600, 1024);
                System.Diagnostics.Debug.WriteLineIf(DEBUG, "ssh: connected");
                return true;
            }
            catch (System.Exception e)
            {
                System.Diagnostics.Debug.WriteLineIf(DEBUG, "ssh: error while connecting:");
                System.Diagnostics.Debug.WriteLine(e.Message);
                System.Diagnostics.Debug.WriteLine(e.InnerException);
                return false;
            }
        }

Usage Example

Exemplo n.º 1
0
        public bool Connect(string host, ushort port, string user, string pw)
        {
            if (!_connected && !_disconnecting)
            {
                _sendQueue.Clear();
                _receiveQueue.Clear();
                _rsConnector = new RSSSHConnector(this, host, port, user, pw);
                if (_rsConnector.Connect())
                {
                    _rsProtoBuf = new RSProtoBuf(_rsConnector.Stream, _sendQueue, _receiveQueue, this);
                    _connected  = true;
                    _run        = true;

                    _t          = new Thread(new ThreadStart(ProcessNewMsgLoop));
                    _t.Name     = "Process new msg loop";
                    _t.Priority = ThreadPriority.Normal;
                    _t.Start();

                    return(true);
                }
            }
            return(false);
        }