示例#1
0
        private void CloseSocket()
        {
            Debug.Assert(null != m_RecvEventArgs);
            Debug.Assert(null != m_SendEventArgs);

            m_State = SESSION_STATE.CLOSED;

            if (null != m_Socket)
            {
                if (m_Socket.Connected)
                {
                    m_Socket.Shutdown(SocketShutdown.Both);
                }

                m_Socket.Close();
                m_Socket = null;
            }

            if (null != m_RecvEventArgs)
            {
                m_RecvEventArgs.UserToken = null;
            }

            if (null != m_SendEventArgs)
            {
                m_SendEventArgs.UserToken = null;
            }

            if (null != m_Object)
            {
                m_Object = null;
            }

            m_SendBuffer.SetEmpty();
            m_ReceiveBuffer.SetEmpty();
        }