Exemple #1
0
        private void Accept(IAsyncResult result)
        {
            HTTPSession session = null;

            try
            {
                Socket theSocket = this.MainSocket.EndAccept(result);
                lock (this.SessionTable)
                {
                    session                    = new HTTPSession(this.LocalIPEndPoint, theSocket);
                    session.OnClosed          += new HTTPSession.SessionHandler(this.CloseSink);
                    session.OnHeader          += new HTTPSession.ReceiveHeaderHandler(this.HandleHeader);
                    session.OnReceive         += new HTTPSession.ReceiveHandler(this.HandleRequest);
                    this.SessionTable[session] = session;
                }
                this.SessionTimer.Add(session, 3);
                this.OnSessionEvent.Fire(this, session);
                session.StartReading();
            }
            catch (Exception exception)
            {
                if (exception.GetType() != typeof(ObjectDisposedException))
                {
                    EventLogger.Log(exception);
                }
            }
            try
            {
                this.MainSocket.BeginAccept(new AsyncCallback(this.Accept), null);
            }
            catch (Exception)
            {
            }
        }
        private void Accept(IAsyncResult result)
        {
            HTTPSession WebSession = null;

            try
            {
                Socket AcceptedSocket = MainSocket.EndAccept(result);
                lock (SessionTable)
                {
                    WebSession               = new HTTPSession(this.LocalIPEndPoint, AcceptedSocket);
                    WebSession.OnClosed     += new HTTPSession.SessionHandler(CloseSink);
                    WebSession.OnHeader     += new HTTPSession.ReceiveHeaderHandler(HandleHeader);
                    WebSession.OnReceive    += new HTTPSession.ReceiveHandler(HandleRequest);
                    SessionTable[WebSession] = WebSession;
                }
                SessionTimer.Add(WebSession, 3);
                OnSessionEvent.Fire(this, WebSession);
                WebSession.StartReading();
            }
            catch (Exception err)
            {
                if (err.GetType() != typeof(System.ObjectDisposedException))
                {
                    // Error
                    OpenSource.Utilities.EventLogger.Log(err);
                }
            }

            try
            {
                MainSocket.BeginAccept(new AsyncCallback(Accept), null);
            }
            catch (Exception ex)
            {
                OpenSource.Utilities.EventLogger.Log(ex);
                // Socket was closed
            }
        }
Exemple #3
0
        private void Accept(IAsyncResult result)
        {
            HTTPSession WebSession;

            try
            {
                Socket AcceptedSocket = MainSocket.EndAccept(result);
                lock (SessionTable)
                {
                    WebSession               = new HTTPSession(LocalIPEndPoint, AcceptedSocket);
                    WebSession.OnClosed     += CloseSink;
                    WebSession.OnHeader     += HandleHeader;
                    WebSession.OnReceive    += HandleRequest;
                    SessionTable[WebSession] = WebSession;
                }
                SessionTimer.Add(WebSession, 3);
                OnSessionEvent.Fire(this, WebSession);
                WebSession.StartReading();
            }
            catch (Exception err)
            {
                if (err.GetType() != typeof(ObjectDisposedException))
                {
                    // Error
                    EventLogger.Log(err);
                }
            }

            try
            {
                MainSocket.BeginAccept(Accept, null);
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                // Socket was closed
            }
        }