lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Re: Problem on using DNS function in app


From: Bei Guan
Subject: Re: [lwip-users] Re: Problem on using DNS function in app
Date: Fri, 19 Nov 2010 09:34:48 +0800

I got it.
I did not Initialize the resolver. So I add the function dns_init(), which sets up the UDP pcb and configures the default server, before calling netconn_gethostbyname and it works.
Thank all of you!

Bei Guan


2010/11/19 David Empson <address@hidden>
I assume you are initializing LWIP via a call to tcip_init()? If so, the DNS module should be correctly initialized, which eliminates one possible reason for an ERR_VAL result. Your parameters look OK, which rules out all the other "immediate error" results which can return ERR_VAL.
 
(I've just filed a bug report, as the init/parameter error conditions are supposed to return ERR_ARG but are actually returning ERR_VAL.)
 
ERR_VAL is also returned if there is an invalid response from the DNS sever. The comment in do_dns_found() suggests this could be a timeout or memory error, or the DNS server may have returned an error such as a nonexistent domain name.
 
----- Original Message -----
From: Bei Guan
Sent: Friday, November 19, 2010 4:25 AM
Subject: [lwip-users] Re: Problem on using DNS function in app

Now I can compile successfully. But there are some error and the value of the error is -9, which means "Illegal value".

My code:
char hname[]="www.baidu.com";
struct ip_addr addr;
err_t err;
if ((err = netconn_gethostbyname((char*)(hname), &(addr))) == ERR_OK) {
   printf("netconn_gethostbyname(%s)==", (char*)(hname));
   ip_addr_debug_print(LWIP_DBG_ON, (&addr));
   printf("\n");
} else {
   printf("netconn_gethostbyname(%s)==%i\n", (char*)(hname), (int)(err));
}

And the output:
netconn_gethostbyname(www.baidu.com)==-9


So why the DNS can not work?

2010/11/18 Bei Guan <address@hidden>
Hi all,

I have used the function netconn_gethostbyname in my program. I have set the #define LWIP_DNS 1 in lwipopts.h and I also have include the "lwip/api.h" before my main function. When I compile my program, it came cross an error message: undefined reference to `netconn_gethostbyname'. But some other function can be used successfully, such as netconn_connect.

So anyone can give me advice. Thanks a lot!

_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users


reply via email to

[Prev in Thread] Current Thread [Next in Thread]