I was trying DNS resolver to IP address and was successful in implementing it. But the problem I am facing is when there is No, internet at that time also I am getting the IP of the DNS and I am unable to clear it.
Is there any method from which I can clear the cache of the esp32 or I can clear the place where the data is been stored.
My code is as follows.
Code: Select all
while (1)
{
printf("Get IP for URL: %s\n", szURL);
dns_gethostbyname(szURL, &ip_Addr, dns_found_cb, NULL);
while (!bDNSFound)
;
if (bDNSFound == true)
{
printf("DNS found: %i.%i.%i.%i\n",
ip4_addr1(&ip_Addr.u_addr.ip4),
ip4_addr2(&ip_Addr.u_addr.ip4),
ip4_addr3(&ip_Addr.u_addr.ip4),
ip4_addr4(&ip_Addr.u_addr.ip4));
// bDNSFound = 0;
int ret = 0;
ret = dns_local_removehost("google.com", &ip_Addr);
printf("return value is: %d\r\n", ret);
}
}
Code: Select all
void dns_found_cb(const char *name, const ip_addr_t *ipaddr, void *callback_arg)
{
if (ipaddr != NULL)
{
ip_Addr = *ipaddr;
bDNSFound = true;
}
}