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

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Mon Apr 8 22:14:27 CEST 2013


waldo kitty wrote:
> On 4/8/2013 14:54, Mark Morgan Lloyd wrote:
>> waldo kitty wrote:
>>> On 4/8/2013 11:03, Mark Morgan Lloyd wrote:
>>>> How best to get the (internet-style) domain name of a system? 
>>>> GetDomainName()
>>>> appears to be returning "(none)" here on x86 Linux.
>>>
>>> do you mean the FQDN (Fully Qualified Domain Name)??
>>
>> I mean that on the machine I'm working on the hostname is pye-dev-01 
>> and the
>> domain name is telemetry.co.uk. I was under the impression that 
>> GetDomainName()
>> should return the latter, but apart from anything else it's unix-only 
>> and whilst
>> Windows is not somewhere I want to go today I'd like a portable 
>> solution if
>> possible.
> 
> ok... you are looking for the FQDN, then... the question is how is this 
> machine referenced and its FQDN created and maintained... it would seem 
> that you would have a DNS server that would return this information... 
> it sounds like your machine only has its host name defined and there is 
> nothing else DNS-wise that returns the rest of the domain name...
> 
> from the machine you are trying to perform this look up from, what do 
> you get if you do the following?
> 
> 
> nslookup pye-dev-01

Server:         192.168.1.1
Address:        192.168.1.1#53

Name:   pye-dev-01.telemetry.co.uk
Address: 192.168.1.16

> nslookup pye-dev-01.telemetry.co.uk

Server:         192.168.1.1
Address:        192.168.1.1#53

Name:   pye-dev-01.telemetry.co.uk
Address: 192.168.1.16

> using the last one, i get the message that that machine doesn't exist... 
> of course, i'm on the outside and access to this machine may not be 
> allowed from outside... not even finding its address...

As you can see, that's an internal (RFC 1918 IIRC) address.

> i don't see this as linux or windows centric... what i'm seeing seems to 
> point to a DNS configuration situation... you might be able to handle 
> this with a local entry in your HOSTS file...
> 
> [crystalball] get nslookup working first. your code should work. 
> [/crystalball]

OK, that's no big deal. But it looks like GetDomainName() doesn't quite 
do what it says on the can :-)

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