Esempio n. 1
0
        public void listenerThread()
        {
            int port;

            int.TryParse(reader.get("this.port"), out port);
            Info("Jsmod2 ProxyHandler is Starting,Port: " + port);
            TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Parse(reader.get("this.ip")), port));

            listener.Start();
            while (true)
            {
                if (!started)
                {
                    ProxyHandler.handler.Info("Proxy Thread is exited");
                    break;
                }
                try
                {
                    TcpClient client = listener.AcceptTcpClient();
                    Info("listened a request from Jsmod2");
                    WorkThread thread = new WorkThread(client);
                    Thread     t      = new Thread(thread.socketThread);
                    t.Start();
                }
                catch (Exception e)
                {
                    //输出错误日志
                    Error(e.Message);
                    Error(e.GetType() + "");
                    Error(e.StackTrace);
                }
            }
        }
Esempio n. 2
0
        public void listenerThread()
        {
            TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 19938));

            listener.Start();
            while (true)
            {
                TcpClient  client = listener.AcceptTcpClient();
                WorkThread thread = new WorkThread(client);
                ThreadPool.QueueUserWorkItem(new WaitCallback(thread.socketThread));
            }
        }