I got following results:
c:\Perl\bin>perl -MSocket -E "say $Socket::VERSION"
2.006
c:\Perl\bin>perl -MIO::Socket::IP -E "say $IO::Socket::IP::VERSION"
0.17
About the code:
my $sock = IO::Socket->new(
Domain => PF_INET6,
LocalPort => 0,
Listen => 1,
) or die "Cannot create socket - $@\n";
Yes, it worked but unfortunately bound to 0.0.0.0, where I was expecting ::
(It seems PF_INET6 is ignored somehow)
Following is the netstat result:
C:\Users\Administrator>netstat -nao | findstr 9999
TCP 0.0.0.0:9999 0.0.0.0:0 LISTENING 10180
A similar socket6 code :
use Socket;
use Socket6;
@res = getaddrinfo('::1', 9999, AF_UNSPEC, SOCK_STREAM);
while(scalar(@res)>=5){
($family, $socktype, $proto, $saddr, $canonname, @res) = @res;
($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
print ("\nhost= $host port = $port");
socket(Socket_Handle, $family, $socktype, $proto) || next;
bind(Socket_Handle,$saddr ) || die "bind: $!";
listen(Socket_Handle, 5) || die "listen: $!";
$paddr = accept(Client, Socket_Handle);
}
Gives output (when ran on the same setup):
c:\Perl\bin>perl c:\socket6Server.pl
host= ::1 port = 9999
Following is the netstat result:
c:\Perl\bin>netstat -nao | findstr 9999
TCP [::1]:9999 [::]:0 LISTENING 3356
On Tue, Aug 21, 2012 at 9:22 PM, Paul Evans via RT <
bug-IO-Socket-IP@rt.cpan.org> wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=79110 >
>
> On Tue Aug 21 08:01:55 2012, ravale.sushant@gmail.com wrote:
> > Followings are the details of my environment:
> >
> > *OS* : Windows Server 2008 R2 Enterprise
> >
> > *Perl* :
> > c:\Perl\bin>perl -v
> >
> > This is perl 5, version 14, subversion 2 (v5.14.2) built for
> > MSWin32-x86-multi-
> > hread
> > (with 1 registered patch, see perl -V for more detail)
> >
> > Copyright 1987-2011, Larry Wall
> >
> > Binary build 1402 [295342] provided by ActiveState
> >
http://www.ActiveState.com
> > Built Oct 7 2011 15:49:44
> >
> > Extra modules installed through ppm:
> >
> > Socket
> > IO::Socket::IP
>
> Could you please let me know the versions of these two?
>
> $ perl -MSocket -E 'say $Socket::VERSION'
>
> $ perl -MIO::Socket::IP -E 'say $IO::Socket::IP::VERSION'
>
c:\Perl\bin>perl -MSocket -E "say $Socket::VERSION"
2.006
c:\Perl\bin>perl -MIO::Socket::IP -E "say $IO::Socket::IP::VERSION"
0.17
Show quoted text>
> > Socket::GetAddrInfo
>
> This isn't required any more, as Socket 1.97 provides all the right parts.
>
> > Sample code ran:
> >
> > use IO::Socket::IP -register;
> >
> > my $sock = IO::Socket->new(
> > Domain => PF_INET6,
> > LocalHost => "::1",
> > Listen => 1,
> > ) or die "Cannot create socket - $@\n";
> >
> > print "Created a socket of type " . ref($sock) . "\n";
> >
> > source :
> >
http://search.cpan.org/~pevans/IO-Socket-IP-0.17/lib/IO/Socket/IP.pm
> >
> > Actual Output :
> >
> > c:\Perl\bin>perl c:\iosockip.pl
> > Cannot create socket - no address associated with nodename
>
> That looks like it's upset about binding to "::1". It may be you don't
> have one, or for some other reason that can't be done.
>
> I'm not too familiar with Windows, but perhaps you could try instead:
>
> my $sock = IO::Socket->new(
> Domain => PF_INET6,
> LocalPort => 0,
> Listen => 1,
> ) or die "Cannot create socket - $@\n";
>
> which avoids providing the local hostname directly.
>
> Ofcourse in any real application you'd likely put your application's
> port number here rather than 0.
>
> --
>
> Paul Evans
>