Answers

Question and Answer:

  Home  Brew

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

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);

}

 165 views

More Questions for you: