Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 gethostbyaddr inconsistency on 'localhost' #10724

Open
p5pRT opened this issue Oct 13, 2010 · 3 comments
Open

Win32 gethostbyaddr inconsistency on 'localhost' #10724

p5pRT opened this issue Oct 13, 2010 · 3 comments
Labels
Closable? We might be able to close this ticket, but we need to check with the reporter distro-All distro-mswin32 type-library type-portability

Comments

@p5pRT
Copy link

p5pRT commented Oct 13, 2010

Migrated from rt.perl.org#78364 (status was 'open')

Searchable as RT78364$

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2010

From @kmx

Created by @kmx

The following code​:

use Socket;
my $addr = gethostbyname('localhost');
my $name = gethostbyaddr($addr, AF_INET);
my $ip = inet_ntoa($addr);
print "name=$name\nip=$ip\n";

has according my tests different behaviour on MS Windows and Linux.

Output on MS Windows​:
name=MYPCNAME.domain.cz
ip=127.0.0.1

Output on Linux​:
name=localhost.localdomain
ip=127.0.0.1

I am not sure if this is intended behaviour; however I have a feeling that
it would have been more correct if the $name variable in my example had
returned something like 'localhost'.

SIDE NOTE1​: this issue makes troubles on Win32 when using HTTP​::Daemon like
this​:

use HTTP​::Daemon;
my $srv = HTTP​::Daemon->new(LocalAddr => 'localhost​:8080');
print "url=", $srv->url;

on Windows box the example above prints​:
url=http​://MYPCNAME.domain.cz​:8080/
however the daemon listens just on 127.0.0.1​:8080 so the $srv->url is invalid.

The trouble is that HTTP​::Daemon is calling gethostbyaddr() in a similar
way as I have shown in the first example.

SIDE NOTE2​: due to this HTTP​::Daemon issue installation of WWW​::Mechanize
on Win32 fails during its tests

Thanks in advance for any feedback.

--
kmx

Perl Info

Flags:
    category=library
    severity=low
    module=Socket

Site configuration information for perl 5.12.1:

Configured by 1 at Thu Jul 29 16:39:48 2010.

Summary of my perl5 (revision 5 version 12 subversion 1) configuration:
   
  Platform:
    osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
    uname='Win32 strawberryperl 5.12.1.0 #1 Thu Jul 29 10:08:11 2010 i386'
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT 
-DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-fno-strict-aliasing -mms-bitfields -DPERL_MSVCRT_READFIX',
    optimize='-s -O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='4.4.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long long',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-s -L"D:\strawberry32\perl\lib\CORE"
-L"D:\strawberry32\c\lib"'
    libpth=D:\strawberry32\c\lib D:\strawberry32\c\i686-w64-mingw32\lib
    libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=, so=dll, useshrplib=true, libperl=libperl512.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -s -L"D:\strawberry32\perl\lib\CORE"
-L"D:\strawberry32\c\lib"'

Locally applied patches:
    


@INC for perl 5.12.1:
    D:/strawberry32/perl/site/lib
    D:/strawberry32/perl/vendor/lib
    D:/strawberry32/perl/lib
    .


Environment for perl 5.12.1:
    HOME=C:\Users\kmx
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=D:\strawberry32\\perl\site\bin;D:\strawberry32\\perl\bin;D:\strawberry32\\c\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
    PERL_BADLANG (unset)
    PERL_MM_USE_DEFAULT=1
    SHELL (unset)


@p5pRT
Copy link
Author

p5pRT commented Oct 22, 2010

@khwilliamson - Status changed from 'new' to 'open'

@richardleach
Copy link
Contributor

By Strawberry Perl v5.30.0 on Win 10:

  • WWW::Mechanize installs okay, passing all tests that it hasn't skipped
  • HTTP::Daemon also installs okay (looked like it did anyway, but FYI)
  • running the "SIDE NOTE1" code results in a URL containing the localhost IP address (IPv6 in this case), rather than the FQDN for the host:
C:\fldr>perl sidenote1.pl
url=http://[::1]:8080/

@kmx - are you happy with the current behaviour or is there still something to be done?

@xsawyerx xsawyerx added the Closable? We might be able to close this ticket, but we need to check with the reporter label Dec 29, 2019
@xenu xenu removed the Severity Low label Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closable? We might be able to close this ticket, but we need to check with the reporter distro-All distro-mswin32 type-library type-portability
Projects
None yet
Development

No branches or pull requests

5 participants