2019-07-21 06:39 PM
cpu : stm32f4
I want to get the IP address using dns_gethostbyname. However, I can not get the IP address
How do I get the IP address ?
( I set the DNS service using stm32cubeMX.)
==================================
void main(void)
{
int test=dns_gethostbyname("www.freertos.com",&resolved,dns_found,NULL);
}
void dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
{
uint8_t ip[4];
ip_addr_t result = *ipaddr;
ip[0] = result.addr>>24;
ip[1] = result.addr>>16;
ip[2] = result.addr>>8;
ip[3] = result.addr;
printf("%d.%d.%d.%d\n",ip[3], ip[2], ip[1], ip[0]);
}
=================================================