[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Is there a trick to gethostbyname()?



Hi,

I'm fighting with gethostbyname(). I notice in the MacPerl list archives
that someone in the dim past complained that it doesn't return anything for
them. For me, when the w3http.pm code (a part of w3mir, included on the
Perl5 CD-ROM included with the MacPerl book) says

my $thishost = hostname();
( my $name, undef ) = gethostbyname( $thishost );

I also suffer the same fate, in that the results are that $name is
undefined. According to the Unix man page,

"And Lo, for the gethostbyname() function returns a structure  of
type hostent  for  the  given host name.  Here name is either a
host name, or an IPv4 address in standard dot notation, or
an IPv6 address in colon (and possibly dot) notation. (See
RFC 1884 for the description of IPv6 addresses.)  If  name
doesn't  end in a dot and the environment variable HOSTALIASES
is set, the alias file  pointed  to  by  HOSTALIASES
will  first  be searched for name (see hostname(7) for the
file format).  The current  domain  and  its  parents  are
searched unless name ends in a dot."

Should there be something I need to set in a Mac OS control panel somewhere
to get this to fly? The machine is configured for TCP/IP and has an IP
address. The hostname function appears to provide the name of the machine
indicated in the File Sharing control panel.

tnx.,

-m



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch