Example #1
0
File: Client.cs Project: loye/Proxy
 public void StartRelay()
 {
     try
     {
         ClientSocket.BeginReceive(ClientBuffer, 0, ClientBuffer.Length, SocketFlags.None, this.OnClientReceive, ClientSocket);
         RemoteSocket.BeginReceive(RemoteBuffer, 0, RemoteBuffer.Length, SocketFlags.None, this.OnRemoteReceive, RemoteSocket);
     }
     catch (Exception ex)
     {
         Dispose();
         Helper.PublishException(ex);
     }
 }
Example #2
0
File: Client.cs Project: loye/Proxy
 // Remote Cycle
 private void OnClientSent(IAsyncResult ar)
 {
     try
     {
         if (ClientSocket.Connected)
         {
             int length = ClientSocket.EndSend(ar);
             if (length > 0 && RemoteSocket.Connected)
             {
                 RemoteSocket.BeginReceive(RemoteBuffer, 0, RemoteBuffer.Length, SocketFlags.None, this.OnRemoteReceive, RemoteSocket);
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         Dispose();
         Helper.PublishException(ex);
     }
     Dispose();
 }