Class KomodiaDNS::CDNSSocket::
ParseAnswer()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: operator =Next page: Receive    Show member index
Public Function Declared in:
DNSSocket.h

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

CDNSAnswers * ParseAnswer(
    char* pBuffer,
    char* pOriginalBuffer,
    int iBufferLengh,
    BOOL bFromThread=FALSE,
    BOOL bTCP=FALSE);

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

Parse the answer

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

try
{
    //Check if we have a thread manager
    if (m_pThreadManager &&
        !bFromThread)
    {
        //Check the buf len
        if (iBufferLengh<=0)
        {
            //Report it
            ReportError("ParseAnswer","Invalid buffer length!");

            //Exit
            return NULL;
        }

        //Create a job
        ParseThreadData* pData;
        pData=new ParseThreadData;

        //Set the data
        pData->pData=pBuffer;
        pData->pOriginalData=pOriginalBuffer;
        pData->iDataSize=iBufferLengh;
        pData->pSocket=this;
        pData->bTCP=bTCP;

        //Submit
        m_pThreadManager->SubmitJob(ThreadProc,
                                    (LPVOID)pData);

        //Exit
        return NULL;
    }

    //Parse the answer
    CDNSAnswers* pAnswers;
    pAnswers=new CDNSAnswers;

    //Try to parse
    int iResult;
    iResult=pAnswers->Parse(pBuffer,
                            iBufferLengh);

    if (!iResult)
    {
        //Delete it, and set to null
        delete pAnswers;
        pAnswers=NULL;

        //Write the error
        ReportError("ParseAnswer","Failed to parse answers");

        //Delete the memory
        delete [] pOriginalBuffer;

        //And exit
        return NULL;
    }

    if (m_bAsync)
        //Inform the manager
        m_pFather->OnDNSReceive(pAnswers);

    if (iResult<iBufferLengh)
    {
        //Check if TCP
        if (bTCP)
            iResult+=2;

        //Change the data and do again
        iBufferLengh-=iResult;
        pBuffer+=iResult;

        //And parse again
        return ParseAnswer(pBuffer,
                           pOriginalBuffer,
                           iBufferLengh,
                           TRUE,
                           bTCP);
    }
    else
        delete [] pOriginalBuffer;

    //Done
    return pAnswers;
}
ERROR_HANDLER_RETURN("ParseAnswer",NULL)

'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.