예제 #1
0
파일: TCP_Server.cs 프로젝트: weikety/ECode
        public TCP_Server(int socketAcceptors = 10)
        {
            if (socketAcceptors <= 0)
            {
                socketAcceptors = 10;
            }
            else if (socketAcceptors > 50)
            {
                socketAcceptors = 50;
            }

            m_AcceptorsPerSocket   = socketAcceptors;
            m_pListeningPoints     = new List <ListeningPoint>();
            m_pConnectionAcceptors = new List <TCP_Acceptor>();
            m_pSessions            = new TCP_SessionCollection <TCP_ServerSession>();
        }
예제 #2
0
파일: TCP_Server.cs 프로젝트: weikety/ECode
        public void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }

            if (m_IsRunning)
            {
                try
                { Stop(); }
                catch (Exception ex)
                {
                    // just skip.
                    string dummy = ex.Message;
                }
            }

            // We must call disposed event before we release events.
            try
            { OnDisposed(); }
            catch (Exception ex)
            {
                // just skip.
                string dummy = ex.Message;
            }

            this.IsDisposed = true;

            m_pSessions.Clear();
            m_pSessions = null;

            // Release all events.
            this.Started        = null;
            this.Stopped        = null;
            this.Error          = null;
            this.Disposed       = null;
            this.WriteLog       = null;
            this.SessionCreated = null;
        }