Example #1
0
        /// <summary>
        /// HttpServer Socket Listener
        /// </summary>
        public void Listen()
        {
            // Create listener and start listening
            while (m_isStarted)
            {
                try
                {
                    _Bind.RequestContext context = m_replyChannel.ReceiveRequest();

                    // The context returned by m_httpListener.GetContext(); can be null in case the service was stopped.
                    if (context != null)
                    {
                        WsHttpMessageProcessor processor = new WsHttpMessageProcessor(m_serviceEndpoints);

                        // Try to get a processing thread and process the request
                        m_threadManager.StartNewThread(processor, context);
                        m_ctx.ContextObject = context.m_context.ContextObject;
                    }
                }
                catch
                {
                    m_ctx.ContextObject = null;
                }
            }
        }
Example #2
0
        public void Stop()
        {
            if (!m_isStarted)
            {
                throw new InvalidOperationException();
            }

            m_isStarted = false;

            WsHttpMessageProcessor.StopProcessing();

            m_replyChannel.Close();
            m_thread.Join();
        }
Example #3
0
        /// <summary>
        /// HttpServer Socket Listener
        /// </summary>
        public void Listen()
        {
            // Create listener and start listening
            int threadCount = 0;

            m_httpListener.Start();
            while (m_requestStop == false)
            {
                HttpListenerContext context;
                try
                {
                    context = m_httpListener.GetContext();
                }
                catch (SocketException e)
                {
                    // If request to stop listener flag is set or locking call is interupted return
                    // The error code 10004 comes from the socket exception.
                    if (m_requestStop == true || e.ErrorCode == 10004)
                    {
                        return;
                    }

                    // Throw on any other error
                    System.Ext.Console.Write("Accept failed! Socket Error = " + e.ErrorCode);
                    throw e;
                }

                // The context returned by m_httpListener.GetContext(); can be null in case the service was stopped.
                if (context != null)
                {
                    WsHttpMessageProcessor processor = new WsHttpMessageProcessor(m_serviceEndpoints, context);

                    if (m_threadManager.ThreadsAvailable == false)
                    {
                        processor.SendError(503, "Service Unavailable");
                        System.Ext.Console.Write("Http max thread count " + threadCount + " exceeded. Request ignored.");
                        // System.Ext.Console.Write("Sending Service Unavailble to: " + sock.RemoteEndPoint.ToString());  Igor
                    }
                    else
                    {
                        // Try to get a processing thread and process the request
                        m_threadManager.StartNewThread(processor);
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// HttpServer Socket Listener
        /// </summary>
        public void Listen()
        {
            // Create listener and start listening
            while (m_isStarted)
            {
                try
                {
                    _Bind.RequestContext context = m_replyChannel.ReceiveRequest();

                    // The context returned by m_httpListener.GetContext(); can be null in case the service was stopped.
                    if (context != null)
                    {
                        WsHttpMessageProcessor processor = new WsHttpMessageProcessor(m_serviceEndpoints, context);

                        if (m_threadManager.ThreadsAvailable == false)
                        {
                            WsWsaHeader header = new WsWsaHeader();

                            context.Reply(WsFault.GenerateFaultResponse(header, WsFaultType.WsaEndpointUnavailable, "Service Unavailable (busy)", context.Version));

                            System.Ext.Console.Write("Http max thread count exceeded. Request ignored.");
                        }
                        else
                        {
                            // Try to get a processing thread and process the request
                            m_threadManager.StartNewThread(processor);
                        }
                    }
                }
                catch
                {
                    if (!m_isStarted)
                    {
                        break;
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// HttpServer Socket Listener
        /// </summary>
        public void Listen()
        {
            // Create listener and start listening
            while (m_isStarted)
            {
                try
                {
                    _Bind.RequestContext context = m_replyChannel.ReceiveRequest();

                    // The context returned by m_httpListener.GetContext(); can be null in case the service was stopped.
                    if (context != null)
                    {
                        WsHttpMessageProcessor processor = new WsHttpMessageProcessor(m_serviceEndpoints);

                        // Try to get a processing thread and process the request
                        m_threadManager.StartNewThread(processor, context);
                        m_ctx.ContextObject = context.m_context.ContextObject;
                    }
                }
                catch
                {
                    m_ctx.ContextObject = null;
                }
            }
        }
Example #6
0
        /// <summary>
        /// HttpServer Socket Listener
        /// </summary>
        public void Listen()
        {
            // Create listener and start listening
            int threadCount = 0;
            m_httpListener.Start();
            while (m_requestStop == false)
            {
                HttpListenerContext context;
                try
                {
                    context = m_httpListener.GetContext();
                }
                catch (SocketException e)
                {
                    // If request to stop listener flag is set or locking call is interupted return
                    // The error code 10004 comes from the socket exception.
                    if (m_requestStop == true || e.ErrorCode == 10004)
                        return;

                    // Throw on any other error
                    System.Ext.Console.Write("Accept failed! Socket Error = " + e.ErrorCode);
                    throw e;
                }

                // The context returned by m_httpListener.GetContext(); can be null in case the service was stopped.
                if (context != null)
                {
                    WsHttpMessageProcessor processor = new WsHttpMessageProcessor(m_serviceEndpoints, context);

                    if (m_threadManager.ThreadsAvailable == false)
                    {
                        processor.SendError(503, "Service Unavailable");
                        System.Ext.Console.Write("Http max thread count " + threadCount + " exceeded. Request ignored.");
                        // System.Ext.Console.Write("Sending Service Unavailble to: " + sock.RemoteEndPoint.ToString());  Igor
                    }
                    else
                    {
                        // Try to get a processing thread and process the request
                        m_threadManager.StartNewThread(processor);
                    }
                }
            }
        }
        /// <summary>
        /// HttpServer Socket Listener
        /// </summary>
        public void Listen()
        {
            // Create listener and start listening
            while (m_isStarted)
            {
                try
                {
                    _Bind.RequestContext context = m_replyChannel.ReceiveRequest();

                    // The context returned by m_httpListener.GetContext(); can be null in case the service was stopped.
                    if (context != null)
                    {
                        WsHttpMessageProcessor processor = new WsHttpMessageProcessor(m_serviceEndpoints, context);

                        if (m_threadManager.ThreadsAvailable == false)
                        {
                            WsWsaHeader header = new WsWsaHeader();
                            
                            context.Reply(WsFault.GenerateFaultResponse(header, WsFaultType.WsaEndpointUnavailable, "Service Unavailable (busy)", context.Version));

                            System.Ext.Console.Write("Http max thread count exceeded. Request ignored.");
                        }
                        else
                        {
                            // Try to get a processing thread and process the request
                            m_threadManager.StartNewThread(processor);
                        }
                    }
                }
                catch
                {
                    if (!m_isStarted)
                    {
                        break;
                    }
                }
            }
        }