Class CSocketPool::
Connect()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: ConnectNext page: CSocketPool    Show member index
Public Function Declared in:
SocketPool.h

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

BOOL Connect(
    const std::string& rAddress,
    unsigned short usPort,
    CSocketPoolSocket* pSocket);

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

Another type of connect

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

try
{
    //Protect the socket
    std::auto_ptr<CSocketPoolSocket> pProtection(pSocket);

    //Are we closing
    if (m_bClosing)
        return TRUE;

    //Set the connection data
    pSocket->SetConnectionData(rAddress,
                               usPort);

    //Lock the CSection
    CCriticalAutoRelease aRelease(m_pCSection);

    //Do we have enough space
    if (m_iActiveSockets>=m_iMaxSocket)
    {
        //Can we add to queue
        if (m_aQueue.size()>m_iMaxBackQueue)
            return FALSE;

        //Add the data to the queue
        m_aQueue.push_back(pSocket);

        //Release the protection
        pProtection.release();

        //Exit
        return TRUE;
    }

    //Get the socket
    ++m_iActiveSockets;

    //Exit the CS
    aRelease.Exit();

    //Try to connect
    if (!pSocket->Connect())
    {
        //Check the reconnect
        CheckQueue();

        //Exit
        return FALSE;
    }
    else
    {
        //Release the protection
        pProtection.release();

        //Exit
        return TRUE;
    }
}
ERROR_HANDLER_RETURN("Connect",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.