Ejemplo n.º 1
0
Archivo: Client.cs Proyecto: loye/Proxy
 // Client Cycle
 private void OnClientReceive(IAsyncResult ar)
 {
     try
     {
         if (ClientSocket.Connected)
         {
             int length = ClientSocket.EndReceive(ar);
             if (length > 0 && RemoteSocket.Connected)
             {
                 RemoteSocket.BeginSend(ClientBuffer, 0, length, SocketFlags.None, new AsyncCallback(this.OnRemoteSent), RemoteSocket);
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         Dispose();
         Helper.PublishException(ex);
     }
     Dispose();
 }
Ejemplo n.º 2
0
 private void OnConnected(IAsyncResult ar)
 {
     try
     {
         RemoteSocket.EndConnect(ar);
         if (this.requestType == "CONNECT")
         {
             string respose = string.Format(ErrorPages.HTTPS_CONNECTED, this.httpVersion);
             ClientSocket.BeginSend(Encoding.ASCII.GetBytes(respose), 0, respose.Length, SocketFlags.None, this.OnRequestSent, ClientSocket);
         }
         else
         {
             string request = RebuildQuery();
             Helper.Debug(request.Substring(0, request.IndexOf("\r\n") + 2), ConsoleColor.Green);
             RemoteSocket.BeginSend(Encoding.ASCII.GetBytes(request), 0, request.Length, SocketFlags.None, this.OnRequestSent, RemoteSocket);
         }
     }
     catch (Exception ex)
     {
         Dispose();
         Helper.PublishException(ex);
     }
 }