![]() |
GetAIPAnswer() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Public Function |
Declared in: DNSAnswers.h |
unsigned long GetAIPAnswer() const;
Get the first A/IP answer (if you expect many answers, request it with the vector)
try { //Do we have an answer ? if (!m_aDNSHeader.usANCount || m_aAnswers.empty()) return 0; //Get the answer const CDNSAnswer& rAnswer=m_aAnswers[0]; //Check what type is it ? if (rAnswer.GetResourceType()==CDNSQuery::A) { //Get the data std::string sData; sData=rAnswer.GetData(); //Convert it to long return atol(sData.c_str()); } else if (rAnswer.GetResourceType()==CDNSQuery::MX && m_aDNSHeader.usARCount) { //Look for the additional resources int iPos; iPos=m_aDNSHeader.usANCount+ m_aDNSHeader.usNSCount; //Our data std::string sData; sData=rAnswer.GetData(); //Loop them for (int iCount=0; iCount<m_aDNSHeader.usARCount; iCount++) { //Get the answer const CDNSAnswer& rARAnswer=m_aAnswers[iCount+iPos]; //Is it an A record? if (rARAnswer.GetResourceType()==CDNSQuery::A && rARAnswer.GetName()==sData) //This is us return atol(rARAnswer.GetData().c_str()); } //Not found return 0; } else return 0; } ERROR_HANDLER_RETURN("GetAIPAnswer",0)
![]() |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |