예제 #1
0
        public virtual void Dispose(bool flush)
        {
            if (m_Socket == null || m_Disposing)
            {
                return;
            }

            m_Disposing = true;

            if (flush)
            {
                flush = Flush();
            }

            try
            {
                m_Socket.Shutdown(SocketShutdown.Both);
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            try
            {
                m_Socket.Close();

                SocketPool.ReleaseSocket(m_Socket);
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            if (m_RecvBuffer != null)
            {
                m_ReceiveBufferPool.ReleaseBuffer(m_RecvBuffer);
            }

            m_Socket = null;

            m_Buffer     = null;
            m_RecvBuffer = null;
            m_OnReceive  = null;
            m_OnSend     = null;
            m_Running    = false;

            m_Disposed.Enqueue(this);

            if (/*!flush &&*/ !m_SendQueue.IsEmpty)
            {
                lock (m_SendQueue)
                    m_SendQueue.Clear();
            }
        }
예제 #2
0
        public virtual void Dispose(bool flush)
        {
            // Genova: Usuário desconectando do servidor...
            if (m_Mobile is Mobile)
            {
                ControladorODBC.ODBCDispose(m_Mobile);
            }

            if (m_Socket == null || m_Disposing)
            {
                return;
            }

            m_Disposing = true;

            if (flush)
            {
                flush = Flush();
            }

            try {
                m_Socket.Shutdown(SocketShutdown.Both);
            } catch (SocketException ex) {
                TraceException(ex);
            }

            try {
                m_Socket.Close();

                SocketPool.ReleaseSocket(m_Socket);
            } catch (SocketException ex) {
                TraceException(ex);
            }

            if (m_RecvBuffer != null)
            {
                m_ReceiveBufferPool.ReleaseBuffer(m_RecvBuffer);
            }

            m_Socket = null;

            m_Buffer     = null;
            m_RecvBuffer = null;
            m_OnReceive  = null;
            m_OnSend     = null;
            m_Running    = false;

            m_Disposed.Enqueue(this);

            if (/*!flush &&*/ !m_SendQueue.IsEmpty)
            {
                lock (m_SendQueue)
                    m_SendQueue.Clear();
            }
        }
예제 #3
0
        private void Release(Socket socket)
        {
            try {
                socket.Shutdown(SocketShutdown.Both);
            } catch (SocketException ex) {
                NetState.TraceException(ex);
            }

            try {
                socket.Close();

                SocketPool.ReleaseSocket(socket);
            } catch (SocketException ex) {
                NetState.TraceException(ex);
            }
        }