Exemplo n.º 1
0
        public override int WaitForRequestBytes()
        {
            if (bufferIndex == -1)
            {
                return(m_conn.WaitForRequestBytes());
            }

            return(initialBytes.Length - bufferIndex);
        }
Exemplo n.º 2
0
        private void ServeConnection(Socket acceptedSocket)
        {
            if (!_shutdownInProgress)
            {
                //Connection conn = new Connection(this, acceptedSocket, (System.Security.Cryptography.X509Certificates.X509Certificate)certificate);
                Connection conn = new Connection(this, acceptedSocket);

                if (conn.WaitForRequestBytes() == 0)
                {
                    conn.WriteErrorAndClose(400);
                    return;
                }

                ProcessRequest(conn);
            }
        }
Exemplo n.º 3
0
        public void Start()
        {
            _socket = CreateSocketBindAndListen(AddressFamily.InterNetwork, _ipAddress, _port);

            //start the timer
            DecrementRequestCount();

            ThreadPool.QueueUserWorkItem(delegate
            {
                while (!_shutdownInProgress)
                {
                    try
                    {
                        Socket acceptedSocket = _socket.Accept();

                        ThreadPool.QueueUserWorkItem(delegate
                        {
                            if (!_shutdownInProgress)
                            {
                                Connection conn = new Connection(this, acceptedSocket);

                                if (conn.WaitForRequestBytes() == 0)
                                {
                                    conn.WriteErrorAndClose(400);
                                    return;
                                }

                                Host host = GetHost();

                                if (host == null)
                                {
                                    conn.WriteErrorAndClose(500);
                                    return;
                                }

                                IncrementRequestCount();
                                host.ProcessRequest(conn);
                            }
                        });
                    }
                    catch
                    {
                        Thread.Sleep(100);
                    }
                }
            });
        }
Exemplo n.º 4
0
        public void StartWithoutAssemblies()
        {
            _socket = CreateSocketBindAndListen(AddressFamily.InterNetwork, _ipAddress, _port);

            //start the timer
            DecrementRequestCount();

            ThreadPool.QueueUserWorkItem(delegate
                                             {
                                                 while (!_shutdownInProgress)
                                                 {
                                                     try
                                                     {
                                                         Socket acceptedSocket = _socket.Accept();

                                                         ThreadPool.QueueUserWorkItem(delegate
                                                                                          {
                                                                                              if (!_shutdownInProgress)
                                                                                              {
                                                                                                  var conn =
                                                                                                      new Connection(
                                                                                                          this,
                                                                                                          acceptedSocket);

                                                                                                  if (
                                                                                                      conn.
                                                                                                          WaitForRequestBytes
                                                                                                          () == 0)
                                                                                                  {
                                                                                                      conn.
                                                                                                          WriteErrorAndClose
                                                                                                          (400);
                                                                                                      return;
                                                                                                  }

                                                                                                  Host host = GetHost();

                                                                                                  if (host == null)
                                                                                                  {
                                                                                                      conn.
                                                                                                          WriteErrorAndClose
                                                                                                          (500);
                                                                                                      return;
                                                                                                  }

                                                                                                  IncrementRequestCount();
                                                                                                  host.ProcessRequest(
                                                                                                      conn);
                                                                                              }
                                                                                          });
                                                     }
                                                     catch
                                                     {
                                                         Thread.Sleep(100);
                                                     }
                                                 }
                                             });
        }