public static void ProcessTCPClient(Object obj) { TcpClientObject objClient = (TcpClientObject)obj; try { if (TcpHelperUtil.ProcessNames.ContainsKey(objClient.ClientID)) { objClient.ClientName = TcpHelperUtil.ProcessNames[objClient.ClientID]; } else { objClient.ClientName = TcpHelperUtil.GetMainModuleFilepath(objClient.ClientID); TcpHelperUtil.ProcessNames.TryAdd(objClient.ClientID, objClient.ClientName); } DoHttpProcessing(objClient); } catch (Exception ex) { ////TCPClientProcessor.Proxylog.Logger.Error(ex); } finally { if (objClient.Client.Connected) { objClient.Client.Dispose(); } } }
public static void DoAcceptTcpClientCallback(IAsyncResult ar) { // Get the listener that handles the client request. Socket listener = (Socket)ar.AsyncState; // End the operation and display the received data on // the console. Socket client = listener.EndAccept(ar); // client.NoDelay = true; //client.Client.NoDelay = true; TcpClientObject tcp = TcpHelperUtil.GetPortDetails(client); tcp.Client = client; try { tcp.ThreadIndex = ++m_threadIndex; } catch (Exception ex) { ////TCPClientProcessor.Proxylog.Logger.Error(ex); tcp.ThreadIndex = m_threadIndex = 0; } // Signal the calling thread to continue. m_tcpClientConnected.Set(); try { Task.Factory.StartNew(() => TCPClientProcessor.ProcessTCPClient(tcp)); } catch (Exception ex) { ////TCPClientProcessor.Proxylog.Logger.Error(ex); } }