lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] DNS question


From: Pettinato, Jim
Subject: RE: [lwip-users] DNS question
Date: Fri, 14 Aug 2009 13:51:01 -0400

Chuck,

The IP address pointer will be NULL on an error.
See the wiki for more details... http://lwip.wikia.com/wiki/LwIP_wiki

A sample DNS callback:

// callback for DNS queries for SMTP server name
void smtp_serverFound(char *name, struct ip_addr *ipaddr, void
*callback_arg)
{
        if ((ipaddr) && (ipaddr->addr))
        {
                smtp.serverIP.addr = ipaddr->addr;
                smtp.state = SMTP_NAME_RESOLVED;
                if (smtp_connect() == ERR_OK)
                        return;
                smtp.lastError = SMTP_CONNECT_FAILED;
        }
        else
                smtp.lastError = SMTP_UNKNOWN_HOST;
        smtp.state = SMTP_IDLE;
}  

Hope this helps!

- Jim
__
 
James M. Pettinato, Jr.
Software Engineer
E: address@hidden | P: 814 898 5250 

FMC Technologies Measurement Solutions Inc.
1602 Wagner Avenue | Erie PA | 16510 USA 
Phone: 814 898 5000 | Fax: 814 899-3414
www.fmctechnologies.com 

 

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf
Of Chuck Kuecker
Sent: Friday, August 14, 2009 12:09 PM
To: Mailing list for lwIP users
Subject: RE: [lwip-users] DNS question

Does it help to mention that I am using the TI/Luminary Stellaris
library version of LWIP? They don't mention an LWIP revision, just an
overall library revision of 2942.

Chuck

-----Original Message-----
From: address@hidden
[mailto:address@hidden On
Behalf Of Kieran Mansley
Sent: Friday, August 14, 2009 10:41 AM
To: Mailing list for lwIP users
Subject: RE: [lwip-users] DNS question

On Fri, 2009-08-14 at 10:20 -0500, Chuck Kuecker wrote:
> Hi, Kieran,
> 
> My impression was that dns_gethostbyname() would return ERR_OK if it
did
> not encounter anything fatal, but would actually set up the DNS query 
> for transmission in the background, so that dns_gethostbyname()
returns
> immediately, and would only have good information if the resolution
was
> already in the DNS tables.

Take a look at the source.  If it already knows the answer it fills it
in and returns ERR_OK.  Otherwise it will work asynchronously and call
the specified callback when it knows the answer (or error, or timeout).

> Since I am booting the processor every time I need to resolve DNS, I 
> can't expect a previously resolved IP to be in memory.

So then it will always work asynchronously.

> The callback always gets called sometime after dns_gethostbyname() is 
> called. I use the argument parameter to let me know which URL I have 
> been working with. In case of a DNS failure, I need to abort further 
> processing.

So if you get an error in your callback set some global state that you
check before doing any processing, and abort the further processing if
that state is set.

Kieran



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


_______________________________________________
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]