Brew Question: Download Brew PDF

Why do we get the value of 0.0.0.0 in dnsresult.addrs when I use GetHostByName()?

Tweet Share WhatsApp

Answer:

This may be due to incorrect implementation of error handling in the GetHostByName() callback function. The error handling implementation in the GetHostByName() callback of the NetSocket example is incorrect. You can use the following sample implementation:

if(pMe->dnsresult.nResult > 0 && pMe->dnsresult.nResult
<= AEEDNSMAXADDRS) {
// DNS lookup success
// Process dnsresult.addrs
for(i = 0; i < pMe->dnsresult.nResult; i++) {
SPRINTF(szMsg,"Addr=: %x",pMe->dnsresult.addrs[i]);
DisplayOutput(pMe,i+4,szMsg);
}
} else {
// DNS Failure - error code is dnsresult.nResult
SPRINTF(szMsg, "DNS: error %d", pMe->dnsresult.nResult);
DisplayOutput(pMe, 2, szMsg);
}

Download Brew PDF Read All 78 Brew Questions
Previous QuestionNext Question
Why does GetHostByName() not work on my phone?With no TCP/IP Flush command available in BREW, how can I confirm that a command is sent right away?