cURL / Mailing Lists / curl-library / Single Mail


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

From: Steve Holme <>
Date: Sun, 21 Aug 2011 19:19:36 +0100

Hiya Daniel,

> (sorry for the major delay)

No problem - I assumed you were busy with more important Curl matters / have
a personal life ;-)

> Argh, that's correct. We don't have anything in libcurl before this that
needs that feature.
> I wonder how large percentage of use cases this will work for anyway. Lots
of machines today that speak SMTP will not be able to resolve their own

I must admit I honestly can't answer that. My own testing of Libcurl has
been performed against Exchange Server 2010 and that doesn't appear to have
any problems. However, I have found various articles around the web that
talk about this problem with the Windows SMTP service.

> Is it really worth persuing or should we work on better documenting how a
client should do to provide the full host name itself?

Good question. How easy / difficult would it be to add the AI_CANONNAME flag
to Curl_resolv()'s underlying functions and what impact would this have on
their performance?

Over the last week I have had some thoughts about the Curl_gethostname()
function and I must admit I really don't like changing the function's
argument list so dramatically (as I did in my example code). If we are to do
this I would much rather we change the behaviour of Curl_gethostname() to
return just the hostname, in a non-fully qualified manner, thus stripping
off the domain if necessary and adding a separate
Curl_getfullyqualifiedhostname() or Curl_getfqhostname() function that calls
Curl_resolv() as required. The benefit of doing this is that the behaviour
of Curl_gethostname() is then defined as returning just the hostname and is
constant across all platforms rather than at present where it may return the
hostname, it may return the fully qualified hostname. The programmer who is
calling the function has no idea what the underlying stack is going to
return unless they perform a test on the string (as is the case of the
existing NTLM code).

If we decide not to modify Curl_resolv()'s underlying functions then I would
still recommend we modify the output of Curl_gethostname() so it returns a
defined value, but we will also need to think of a better way of passing the
fully qualified machine name in the EHLO and HELO commands when talking to
an SMTP server instead of using Curl_gethostname(). In my case, this would
just move the problem from Libcurl to where I am using it as I would still
need to perform an getaddrinfo() to get the fully qualified machine name ;-)

Best Regards


List admin:
Received on 2011-08-21