CC: | avkhozov [...] gmail.com |
Hello!
I'm trying to create a listen socket for ipv6 with IO::Socket::IP in the following way:
and@google:~$ cat t.pl
#!/usr/bin/perl
use IO::Socket::IP;
IO::Socket::IP->new(
Family => AF_INET6,
LocalHost => '::1',
LocalService => '12345',
Listen => 1,
) or die "Cannot create socket - $@\n";
But I get the following error:
and@google:~$ perl t.pl
Cannot create socket - Name or service not known
and@google:~$
I have been investigated this problem and found the source of a problem in getaddrinfo function in glibc. It returns an error if flag
AI_ADDRCONFIG is set. I use the following test:
and@google:~$ cat 1.pl
#!/usr/bin/perl -w
use Socket;
my ($err, @res) = Socket::getaddrinfo('::1', '12345', {
family => AF_INET6,
protocol => Socket::IPPROTO_TCP,
socktype => SOCK_STREAM,
flags => Socket::AI_ADDRCONFIG()
});
warn $err if ($err);
and@google:~$ perl 1.pl
Name or service not known at 1.pl line 11.
and@google:~$
If remove this flags, that is all work fine.
Some info about my library versions:
and@google:~$ perl -MSocket -le 'print $Socket::VERSION'
2.002
and@google:~$ perl -MIO::Socket::IP -le 'print $IO::Socket::IP::VERSION'
0.16
and@google:~$ perl -v
This is perl 5, version 12, subversion 4 (v5.12.4) built for x86_64-linux-gnu-thread-multi
(with 45 registered patches, see perl -V for more detail)
...
and@google:~$ apt-cache show libc6 | egrep -i "^(version|provides)"
Version: 2.13-20ubuntu5
Provides: glibc-2.13-1
Version: 2.13-20ubuntu5.1
Provides: glibc-2.13-1
and@google:~$ uname -a
Linux google 3.0.0-23-generic #38-Ubuntu SMP Fri Jul 6 14:43:30 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
and@google:~$
May be do not use AI_ADDRCONFIG as a default flag while create a socket? ($hints{flags} = ( $arg->{GetAddrInfoFlags} || 0 ) | $AI_ADDRCONFIG;)
Very uncomfortable use PeerAddrInfo in new method.