Class CAsyncSocket::
Shutdown()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: SetTimeoutNext page: SimpleMessageMap    Show member index
Public Function Declared in:
AsyncSocket.h

'Declaration' icon -- Shortcut to top of page. Declaration

static void Shutdown();

'Description' icon -- Shortcut to top of page. Description

Indicate a system shutdown Can be called by user, but will be invoked automatically

'Function Body' icon -- Shortcut to top of page. Function Body

try
{
    //Only if initialized
    if (!m_bInitialized)
        return;

    if (!m_pCSection)
    {
        //Report it
        ReportStaticError(CAsyncSocket_Class,"Shutdown","Critical section not initialized");

        //Exit
        return;
    }

    //Enter the CS
    CCriticalAutoRelease aRelease(m_pCSection);

    //Indicate we're shutting down
    m_bShuttingDown=TRUE;

    //Our vector of sockets
    typedef std::vector<CAsyncSocket*> SocketVector;
    SocketVector aVector;

    //Clear the map
    SocketMap::iterator aIterator;
    aIterator=m_aSocketMap.begin();

    //While not end of the map
    while (aIterator!=m_aSocketMap.end())
    {
        //Add the socket
        aVector.push_back(aIterator->second);

        //Next data
        ++aIterator;
    }

    //Exit the CS
    aRelease.Exit();

    //Iterate the vector
    while (!aVector.empty())
    {
        //Get the socket
        CAsyncSocket* pSocket;
        pSocket=aVector.back();

        //Remove the socket
        aVector.pop_back();

        //Try to delete it
        try
        {
            delete pSocket;
        }
        ERROR_HANDLER_STATIC(CAsyncSocket_Class,"Shutdown - Deletion")
    }

    //Wait for clean up
    Sleep(1000);

    //Delete the thread manager
    if (m_pThreadManager)
    {
        delete m_pThreadManager;
        m_pThreadManager=NULL;
    }

    //Remove the handlers
    RemoveHandlers();

    //Delete the CS
    delete m_pCSection;
    m_pCSection=NULL;
}
ERROR_HANDLER_STATIC(CAsyncSocket_Class,"Shutdown")

'See Also' icon -- Shortcut to top of page. See Also

Class Overview Class Overview  |  Protected base class CSpoofBase  |  Hierarchy Chart Hierarchy Chart


Get Surveyor!This web site was generated using Surveyor V4.50.811.1.  Click here for more information. Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003.