![]() |
ParseAnswer() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: DNSSocket.h |
DeclarationCDNSAnswers * ParseAnswer( char* pBuffer, char* pOriginalBuffer, int iBufferLengh, BOOL bFromThread=FALSE, BOOL bTCP=FALSE);
DescriptionParse the answer
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
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. |