develooper Front page | perl.perl5.porters | Postings from February 2000

Re: fixing Sys::Hostname

Thread Previous | Thread Next
Nick Ing-Simmons
February 7, 2000 14:00
Re: fixing Sys::Hostname
Message ID:
Ilya Zakharevich <> writes:
>Tom Christiansen writes:
>> >Exactly - I have never understood why gethostname() was not built
>> >in in the first place.
>> That would be the cleanest, fastest, and easiest thing to do.
>> One might be able to do so backwards compatibly, too.
>But what will it return?  What *is* a host name?

The name of the host as configured by the sysadmin.
Usually its DNS name or its name withing the default DNS domain.
This is a little problematic for multi-homed-hosts.
In an ideal world it would be a reverse-DNS lookup of the local end
of the "primary" network interface - which would give _an_ 
answer for your SLIP machine... but Dynamic IP farms tend
to botch reverse lookup.

>Suppose I'm behind a temporary-IP-assigned SLIP dialup.  I have
>$ENV{HOSTNAME} set to some internal-use-only value which means nothing
>to the outside world.  What would gethostname() do?

If I recall correctly $ENV{HOSTNAME} is set to whatever gethostname()
returns ;-) - so in this case it would return "internal-use-only value".

Nick Ing-Simmons

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About