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

waldo kitty wkitty42 at windstream.net
Mon Apr 8 23:19:52 CEST 2013


On 4/8/2013 16:14, Mark Morgan Lloyd wrote:
> waldo kitty wrote:
>> 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

i like those outputs :)

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

yup... i kinda figured that was the case...

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

agreed... i was just looking around on my FPC 2.6.0 install and note the 
following from rtl/unix/unix.pp

Function  GetDomainName:String; deprecated; // because linux only.

diggin in, i note that it seems to use the system's uname function... but i 
think that is different than the command line "uname" or "uname -a" because none 
of my linux machine return their FQDN in this output... i note that it also 
seems to be pulling this function from a/the libc library...

i note that both, GetDomainName and GetHostName both use the same var (Sysn : 
utsname) but just different fields in what is apparently a record of some type...

can't trace further... the grill and a pork loin are calling me... not to 
mention other mouths in the location wanting some eats soon-ish...



More information about the fpc-pascal mailing list