Class CSpoofBase::
InitializeSocketsNoMap()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: InitializeSocketsNext page: InitProc    Show member index
Public Function Declared in:
SpoofBase.h

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

static BOOL InitializeSocketsNoMap(
    BOOL bMultiThreaded=TRUE,
    unsigned long ulNumberOfThreads=10);

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

Initialize the sockets, without requiring a message map bMultiThreaded - Do we want multithreaded support ulNumberOfThreads - Number of threads to allocate

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

//To avoid double initialize
if (m_bInitialized)
{
    //Report it
    ReportStaticError(CSpoofBase_Class,"InitializeSocketsNoMap","Already initialized!");

    //Exit
    return TRUE;
}

//Check that the number of threads are OK?
if (ulNumberOfThreads>CLibConfig::GetInstance().GetMaxThreads())
{
    //Report it
    ReportStaticError(CSpoofBase_Class,"InitializeSocketsNoMap","Too many threads!");

    //Exit
    return FALSE;
}

//Do we have threads at all
if (bMultiThreaded &&
    !ulNumberOfThreads)
{
    //Report it
    ReportStaticError(CSpoofBase_Class,"InitializeSocketsNoMap","Didn't receive any threads!");

    //Exit
    return FALSE;
}

try
{
    //Create the thread data
    ThreadData* pThreadData;
    pThreadData=new ThreadData;

    //Populate the data
    pThreadData->pEvent=COSManager::CreateEvent();
    pThreadData->bMultiThreaded=bMultiThreaded;
    pThreadData->ulNumberOfThreads=ulNumberOfThreads;

    //Create the thread
    m_pThread=new CManagedThread(InitProc);
    m_pThread->Start((LPVOID)pThreadData);

    //Wait on the event
    if (pThreadData->pEvent->Wait(THREAD_TIMEOUT))
    {
        //Report it
        ReportStaticError(CSpoofBase_Class,"InitializeSocketsNoMap","Timeout waiting for thread");

        //Delete the thread
        delete m_pThread;
        m_pThread=NULL;

        //Exit
        return FALSE;
    }

    //Are we initialized
    if (!IsInitialized())
    {
        //Delete the thread
        delete m_pThread;
        m_pThread=NULL;
    }

    //Done
    return IsInitialized();
}
ERROR_HANDLER_STATIC_RETURN(CSpoofBase_Class,"InitializeSocketsNoMap",FALSE)

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

Class Overview Class Overview  |  Public base class CErrorHandler  |  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.