cURL / Mailing Lists / curl-library / Single Mail


Re: [PATCH] Curl_gethostname() may or may not return the hostname as a FQDN

From: Daniel Stenberg <>
Date: Thu, 11 Aug 2011 10:39:16 +0200 (CEST)

On Wed, 10 Aug 2011, Steve Holme wrote:

> In addition to this, I also noticed that whilst reworking the NTLM code, in
> http_ntlm.c, it will strip off the domain name if that has been returned
> from Curl_gethostname() - this also tells me that this function should be
> returning the FQDN.

Ok, yes I can see how this is necessary for some uses of this function. I
would however suggest that we add an option to the function so that we don't
spend time to lookup the full name, possibly using a slow DNS server, only to
have the calling code strip off the domain again!

> I would have suggested a call to gethostbyname() but this is deprecated in
> Windows and, from what I have read online, from the current version of the
> POSIX specification due to problems with IPV6.

Welcome to a world of pain. :-)

getaddrinfo() is not present on _lots_ of operating systems that we still
support. gethostbyname() is not thread-safe on lots of operating systems that
we still support. gethostbyname_r() is used in three different ways on
operating systems that we still support... And we offer alternative name
resolver libs like c-ares for them all!

So, to resolve a host name within libcurl we're pretty much forced to use
Curl_resolv() or probably even Curl_resolv_timeout() so that timeouts are
properly acknowledged.

This also has the added benefit that it adds the resolved address to the DNS
cache, should this be needed to get resolved again within a short period of

List admin:
Received on 2011-08-11