Exemplo n.º 1
0
        internal void restartServer()
        {
            clear();

            if (md.ip != "0.0.0.0")
            {
                ServerCtl srv = new ServerCtl();
                lstHttpServer.Add(srv);
                //md.ctl = srv;
                srv.ip = md.ip;
                srv.md = md;
                srv.restartServer();
                return;
            }

            List <string> lstAllIp = ComUtil.findAllIp();

            lstAllIp.Add("localhost");

            HashSet <string> hashUsedIpPort = ComUtil.allUsedIpPort();

            for (int i = 0; i < lstAllIp.Count; ++i)
            {
                int port = findUsedPort(lstAllIp[i], hashUsedIpPort);

                ServerCtl srv = new ServerCtl();
                lstHttpServer.Add(srv);

                srv.ip = lstAllIp[i];
                srv.md = md;

                srv.restartServer();
            }
        }
Exemplo n.º 2
0
        static void GetContextCallBack(IAsyncResult ar)
        {
            try {
                ServerCtl    ctl     = ar.AsyncState as ServerCtl;
                HttpListener sSocket = ctl.httpListener;
                if (sSocket == null || !sSocket.IsListening)
                {
                    return;
                }
                HttpListenerContext context = sSocket.EndGetContext(ar);

                sSocket.BeginGetContext(new AsyncCallback(GetContextCallBack), ctl);

                ctl.responseFile(context);
            } catch (Exception ex) {
                MainWindow.ins.error(ex);
            }
        }