ctcpdnsstm32lwip

How get ip with DNS and LWIP?


I am using STM32F407 and lwip with uC-OS and I want to take ip from dns. I try to call this function.

ip_addr_t TargetIp;
dns_gethostbyname("www.google.com", &TargetIp, NULL, NULL);

But, this function return -5 (ERR_INPROGRESS). In addition if I write "192.168.10.15" instead of "www.google.com" there was no problem. How can I take ip with DNS or another method.


Solution

  • I solved! I fixed function call of dns_gethostbyname

    dns_gethostbyname("www.google.com", &TargetIp, dnsFound, NULL);
    

    and I wrote a callback function which name is dnsFound like this.

    void dnsFound(const char *name, ip_addr_t *ipaddr, void *arg) 
    {       
        dns_gethostbyname("www.google.com", &TargetIp, dnsFound, NULL);
    }