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

Re: fixing Sys::Hostname

Thread Previous
Nick Ing-Simmons
February 6, 2000 08:09
Re: fixing Sys::Hostname
Message ID:
Tom Christiansen <> writes:
>    The inclusion of the nodename member in this structure does not
>    imply that it is sufficient information for interfacing to
>    communications networks.
>The second problem is that the standard requires the nodename field
>to be of no particular size.  On some systems, this results in
>effectively unusable fields containing as few as eight characters--which,
>for reasons of appeasing the hysterical porpoises, must not be
>Here's what we have to do.
>We already at Configure time the check to determine whether the
>system contains gethostname(2).  Yet, we do not let the user call
>it!  We should change the module so that it calls the proper function
>right out of the C library, and stop playing these dumb hacks.  If
>the function does not exist, only then we should call the `hostname`
>program if we can.  It's much faster than pulling in POSIX::uname.
>Only in the absence of gethostname(2) and hostname(1) should uname(3)
>be attempted, since it is apt to be wrong, and very expensive to
>boot.  Even still, you should call it from C, not Perl, so you don't
>pay that insane POSIX module's price for such basic functionality.

Exactly - I have never understood why gethostname() was not built
in in the first place.

Nick Ing-Simmons

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