develooper Front page | perl.perl5.porters | Postings from January 2004

problem with gethostbyname

Thread Next
From:
Daisuke Maki
Date:
January 16, 2004 18:32
Subject:
problem with gethostbyname
Message ID:
40089B33.2010704@wafu.ne.jp
A user on my website has complained to me that my application claims an
existing server is not reacheable.

Upon trying to use the GET utility, it gave me a Bad hostname error.
Then I kept digging down to the bowels of LWP and IO::Socket, and I
think I found that inet_aton refuses to work for this particular server
name.

  [daisuke@sv daisuke]$ ~/perl/bin/perl -e 'use Socket; print
inet_aton("pekoe-.hp.infoseek.co.jp"), "\n"'

  [daisuke@sv daisuke]$

  # if you do this with search.cpan.org, you get the correct structure:
  [daisuke@sv daisuke]$ ~/perl/bin/perl -e 'use Socket; print
inet_aton("search.cpan.org"), "\n"'
  迩
  [daisuke@sv daisuke]$

I looked at ext/Socket/Socket.xs and it seems like gethostbyname() is
not properly handling this:

  [daisuke@sv daisuke]$ ~/perl/bin/perl -e 'use Socket; print
gethostbyname("pekoe-.hp.infoseek.co.jp"), "\n"'

  [daisuke@sv daisuke]$

However, this same host name is readily available from my browser, and
from the "host" command:

  [daisuke@sv daisuke]$ host pekoe-.hp.infoseek.co.jp
  pekoe-.hp.infoseek.co.jp has address 210.148.115.140
  [daisuke@sv daisuke]$

At first sight, that "-" in the servername seems like it's tripping up
Perl, but I'm not sure. I tried tracking down where gethostbyaname() was
implemented, but I kind of lost track of what to look for... Ideas?

I tested this on two flavors of Perl: Perl 5.8.3 on linux, and Perl
5.6.1 on Solaris. Build information for each is included below.

TIA,
--d

Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.4.14, archname=i686-linux
    uname='linux sv.wafu.ne.jp 2.4.14 #7 2001年 11月 21日 水曜日
19:54:05 jst i6
86 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=unde
f
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing
-I/usr/local/include -D_
LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-ggdb',
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-I/usr/inclu
de/gdbm'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1
2.96-98)', gccosa
ndvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize
=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.4'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: DEBUGGING USE_LARGE_FILES
  Built under linux
  Compiled at Jan 15 2004 09:03:00
  @INC:
    /home/daisuke/perl//lib/5.8.3/i686-linux
    /home/daisuke/perl//lib/5.8.3
    /home/daisuke/perl//lib/site_perl/5.8.3/i686-linux
    /home/daisuke/perl//lib/site_perl/5.8.3
    /home/daisuke/perl//lib/site_perl
    .
====

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos modelt 5.6 generic_105181-30 sun4u sparc sunw,ultra-60 '
    config_args='-dr'
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='2.95.1f 19990816 (change 102583)',
gccosandvers='solaris2.5.1'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -lgdbm -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: USE_LARGE_FILES
  Built under solaris
  Compiled at Feb 14 2002 00:15:32
  @INC:
    /usr/local/lib/perl5/5.6.1/sun4-solaris
    /usr/local/lib/perl5/5.6.1
    /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl
    .



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About