[英]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.我在 uC-OS 中使用 STM32F407 和 lwip,我想从 dns 中获取 ip。我尝试将其称为 function。
ip_addr_t TargetIp;
dns_gethostbyname("www.google.com", &TargetIp, NULL, NULL);
But, this function return -5 (ERR_INPROGRESS).但是,这个 function 返回 -5 (ERR_INPROGRESS)。 In addition if I write "192.168.10.15" instead of "www.google.com" there was no problem.
另外,如果我写“192.168.10.15”而不是“www.google.com”,就没有问题。 How can I take ip with DNS or another method.
如何使用 ip 和 DNS 或其他方法。
I solved!我解决了! I fixed function call of dns_gethostbyname
我修复了 dns_gethostbyname 的 function 调用
dns_gethostbyname("www.google.com", &TargetIp, dnsFound, NULL);
and I wrote a callback function which name is dnsFound like this.然后我写了一个回调 function,它的名字是这样的 dnsFound。
void dnsFound(const char *name, ip_addr_t *ipaddr, void *arg)
{
dns_gethostbyname("www.google.com", &TargetIp, dnsFound, NULL);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.