Class KomodiaDNS::CDNSSocket::
Send()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: ReceiveNext page: SetConnectionStatus    Show member index
Public Function Declared in:
DNSSocket.h

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

BOOL Send(
    const char *pBuffer,
    unsigned short bufLen,
    LPVOID lpLocalIDData);

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

Send the buffer

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

try
{
    //Error indicator
    int iError;
    iError=0;

    //Are we TCP
    if (m_bUseTCP)
    {
        //Reconnection status
        BOOL bReconnect;
        bReconnect=FALSE;

        //Enter the CS
        CCriticalAutoRelease aRelease(m_pCSection);

        //Are we disconnected
        if (m_aConnectionStatus==csDisconnected)
            //Try to reinitialize
            if (!Initialize())
            {
                //Write the error
                ReportError("Send","Failed to reinitialize!");

                //Done
                return FALSE;
            }
            else
                m_aConnectionStatus=csNone;

        //What kind of use ?
        if (m_aConnectionStatus==csNone)
        {
            //Set connection to pending
            SetConnectionStatus(csPending);

            //Exit the CS
            aRelease.Exit();

            //connect
            BOOL bResult;
            bResult=m_pTCP->Connect(0,
                                    m_strDNSServer.c_str(),
                                    53,
                                    !m_bAsyncConnect ||
                                    bReconnect);

            //Check for error
            if (!bResult)
            {
                //Set the connection status
                SetConnectionStatus(csNone);

                //Write the error
                ReportError("Send","Failed to connect!");

                //Get the error
                iError=m_pTCP->GetSystemLastError();
            }
            else if (!m_bAsyncConnect ||
                     !m_bAsync ||
                     bReconnect)
                //Set the connection status
                SetConnectionStatus(csConnected);
        }
        else
            aRelease.Exit();

        //Do we need to add to the pool
        if (m_aConnectionStatus!=csConnected &&
            !iError)
            //Add to queue
            AddData(pBuffer,
                    bufLen,
                    lpLocalIDData);
        //Can we send the data
        else if (!iError &&
                 m_aConnectionStatus==csConnected)
        {
            //Try to flush the data
            if (!Flush())
            {
                //Write the error
                ReportError("Send","Failed to flush!");

                //Get the error
                iError=1;
            }
            else if (!m_pTCP->Send(pBuffer,bufLen))
            {
                //Write the error
                ReportError("Send","Failed to send!");

                //Get the error
                iError=m_pTCP->GetSystemLastError();
            }
        }
    }
    else if (m_pUDP->Send(0,
             m_strDNSServer.c_str(),
             53,
             pBuffer,
             bufLen)==CSpoofBase::GetErrorCode())
    {
        //Write the error
        ReportError("Send","Failed to send UDP packet!");

        //Get the error
        iError=m_pUDP->GetSystemLastError();
    }

    //Did we have an error ?
    if (iError)
        //Exit
        return FALSE;
    else
        //Parse the data
        return TRUE;
}
ERROR_HANDLER_RETURN("Send",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.