Example #1
0
        internal DataWaitHandle <SftpPacket> CreateWaitHandle(out uint requestId)
        {
            requestId = CreateRequestId();
            var waitHandle = new DataWaitHandle <SftpPacket>(false, EventResetMode.AutoReset);

            requestWaitHandles.Add(requestId, waitHandle);
            return(requestWaitHandles[requestId]);
        }
Example #2
0
        internal void Start(TcpClient client, string remoteAddress, uint remotePort)
        {
            this.client         = client;
            this.remoteAddress  = remoteAddress;
            this.remotePort     = remotePort;
            this.clientEndpoint = (IPEndPoint)client.Client.RemoteEndPoint;
            this.waitHandle     = new DataWaitHandle <ISshChannelMessage>(false, EventResetMode.AutoReset);

            try
            {
                session.Socket.WritePacket(new SshChannelOpenDirectTcpIP(this.LocalChannel,
                                                                         this.remoteAddress, this.remotePort,
                                                                         this.clientEndpoint.Address.ToString(), (uint)this.clientEndpoint.Port));
                waitHandle.WaitOne();

                this.client.GetStream().BeginRead(clientBuffer, 0, clientBuffer.Length, HandleClient, null);
            }
            catch (SocketException)
            {
                Close(StatusCode.ConnectionRefused);
                throw;
            }
        }