Пример #1
0
        public void Dispose()
        {
            m_IsRunning     = false;
            m_AnyEPListener = null;

            if (m_ThreadRecv != null)
            {
                m_ThreadRecv.Interrupt();
                m_ThreadRecv = null;
            }

            int cnt = m_ListKcp.Count;

            for (int i = 0; i < cnt; i++)
            {
                m_ListKcp[i].Dispose();
            }
            m_ListKcp.Clear();

            if (m_SystemSocket != null)
            {
                try
                {
                    m_SystemSocket.Shutdown(SocketShutdown.Both);
                }
                catch (Exception e)
                {
                    NetworkDebuger.LogWarning("Close() " + e.Message + e.StackTrace);
                }

                m_SystemSocket.Close();
                m_SystemSocket = null;
            }
        }
Пример #2
0
        //=================================================================================
        #region 接收线程

        private void Thread_Recv()
        {
            NetworkDebuger.Log("Thread_Recv() Begin ......");

            while (m_IsRunning)
            {
                try {
                    DoReceive();
                }
                catch (Exception e) {
                    NetworkDebuger.LogError("Thread_Recv() " + e.Message + "\n" + e.StackTrace);
                    Thread.Sleep(10);
                }
            }

            NetworkDebuger.Log("Thread_Recv() End!");
        }