private void Socks5HandshakeSendCallback(IAsyncResult ar)
        {
            var state = (Socks5State)ar.AsyncState;

            try
            {
                _remote.EndSend(ar);

                _remote.BeginReceive(_receiveBuffer, 0, 2, 0, Socks5HandshakeReceiveCallback, state);
            }
            catch (Exception ex)
            {
                state.ex = ex;
                state.Callback?.Invoke(new FakeAsyncResult(ar, state));
            }
        }
Beispiel #2
0
 private void StartPipe(IAsyncResult ar)
 {
     if (_closed)
     {
         return;
     }
     try
     {
         _remote.EndSend(ar);
         _remote.BeginReceive(_remoteRecvBuffer, 0, RecvSize, SocketFlags.None, PipeRemoteReceiveCallback, null);
         _local.BeginReceive(_connetionRecvBuffer, 0, RecvSize, SocketFlags.None, PipeConnectionReceiveCallback, null);
     }
     catch (Exception e)
     {
         Logging.LogUsefulException(e);
         Close();
     }
 }
Beispiel #3
0
 private void StartPipe(IAsyncResult ar)
 {
     if (_closed)
     {
         return;
     }
     try
     {
         _remote.EndSend(ar);
         _remote.BeginReceive(remoteRecvBuffer, 0, RecvSize, 0,
                              new AsyncCallback(PipeRemoteReceiveCallback), null);
         _local.BeginReceive(connetionRecvBuffer, 0, RecvSize, 0,
                             new AsyncCallback(PipeConnectionReceiveCallback), null);
     }
     catch (Exception e)
     {
         Logging.LogUsefulException(e);
         this.Close();
     }
 }
Beispiel #4
0
 public void BeginReceive(byte[] buffer, int offset, int size, SocketFlags socketFlags, AsyncCallback callback,
                          object state)
 {
     _remote.BeginReceive(buffer, offset, size, socketFlags, callback, state);
 }