[fpc-pascal] Portable (or at least working) version of GetDomainName()?

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Tue Apr 9 20:46:44 CEST 2013

waldo kitty wrote:

> i would attempt to go portable by performing a DNS lookup on the address 
> and or the given host name... i don't think i would try to use external 
> programs for this but would compare my results with theirs for the same 
> lookups...

Agreed. I rarely use external programs since there's too much risk 
they're misplaced or of an unexpected version

> FWIW: i also just stumbled over our very similar conversation of a year 
> ago...
>  13 April 2012 - Resolving a local hostnames to an IP address
> http://free-pascal-general.1045716.n5.nabble.com/Resolving-a-local-hostnames-to-an-IP-address-td5637709.html 

So did I. As a quick hack I've parsed /etc/resolv.conf (which covers at 
least the Linux and Solaris cases), falling back to GetDomainName() if 
that fails. That will do for the moment, since it will normally be 
overridden by a .ini file or by something explicitly entered by the user.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list