Exemplo n.º 1
0
        public void Listen()
        {
            bool done = false;

            System.Net.IPAddress localAddr = System.Net.IPAddress.Any;

            listener = new TcpListener(localAddr, portNum);

            listener.Start();

            WriteLog("Listening On: " + portNum.ToString());

            while (!done)
            {
                WriteLog("Waiting for connection...");
                TcpClient client = null;
                try
                {
                    HttpServer.output += "Waiting for connection...\r\n";
                    client             = listener.AcceptTcpClient();
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);

                    return;
                }
                Thread t = new Thread(() =>
                {
                    try
                    {
                        HttpRequestParsing newRequest = new HttpRequestParsing();
                        newRequest.ProcessRequest(client, this);

                        HttpServer.output = newRequest.HTTPRequest.Method;

                        command = new VsMediaCommand(newRequest.HTTPRequest);

                        newRequest.ProcessRespont();
                    }
                    catch (Exception ex)
                    {
                        //System.Windows.Forms.MessageBox.Show("eror in Listen "+ex.Message);
                    }
                });
                t.IsBackground = true;
                t.Priority     = ThreadPriority.Normal;
                t.Start();

                //Thread Thread = new Thread(new ThreadStart(newRequest.Process));
                //Thread.Name = "HTTP Request";
                //Thread.Start();
            }
        }
Exemplo n.º 2
0
        public void Listen()
        {

            bool done = false;

            System.Net.IPAddress localAddr = System.Net.IPAddress.Any;

            listener = new TcpListener(localAddr, portNum);

            listener.Start();

            WriteLog("Listening On: " + portNum.ToString());

            while (!done)
            {
                WriteLog("Waiting for connection...");
                TcpClient client = null;
                try
                {
                    HttpServer.output += "Waiting for connection...\r\n";
                    client = listener.AcceptTcpClient();

                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);

                    return;
                }
                Thread t = new Thread(() =>
                {
                    try
                    {
                        HttpRequestParsing newRequest = new HttpRequestParsing();
                        newRequest.ProcessRequest(client, this);

                        HttpServer.output = newRequest.HTTPRequest.Method;

                        command = new VsMediaCommand(newRequest.HTTPRequest);

                        newRequest.ProcessRespont();
                    }
                    catch (Exception ex)
                    {
                        //System.Windows.Forms.MessageBox.Show("eror in Listen "+ex.Message);

                    }

                });
                t.IsBackground = true;
                t.Priority = ThreadPriority.Normal;
                t.Start();

                //Thread Thread = new Thread(new ThreadStart(newRequest.Process));
                //Thread.Name = "HTTP Request";
                //Thread.Start();
            }

        }