MalcolmH has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl/Windows app that uses TCP/IP sockets and I need to add IPv6 support.

I have a Windows 7 64-bit machine that is running IPv6 with a Hurricane Electric tunnel and it scores 10 out 10 on http://test-ipv6.com/ and will access IPv6-only sites such as http://loopsofzen.co.uk/.

It has ActivePerl 5.14.2 (I also tried Strawberry Perl 5.16.0.1).

Here's a simple test script:

use Socket qw( getaddrinfo ); $host = 'loopsofzen.co.uk'; $port = 80; $hints = (socktype => SOCK_STREAM, family -> Socket::AF_INET6); ($err, @addrs) = getaddrinfo($host, 0); die $err if $err;

and this produces the error:

"no address associated with nodename at ip.pl line 6."

The (new) getaddrinfo() function appears to be available and it does work if I set $host to use an IPv4 hostname. But IPv6 doesn't appear to work at all.

What am I missing? Or is Perl/Windows/IPv6 still a lost cause for the time being?

Replies are listed 'Best First'.
Re: Perl and IPv6 on Windows
by VinsWorldcom (Prior) on Jul 05, 2012 at 16:59 UTC

    I asked about this a while back - see IPv6 Name Resolution.

    The solution for me was to use Socket::GetAddrInfo with the following:

    use if $] < 5.014, "Socket" => qw(inet_ntoa unpack_sockaddr_in IPPROT +O_TCP AF_INET AF_UNSPEC); use if $] < 5.014, "Socket6"; use if $] < 5.014, "Socket::GetAddrInfo" => qw(getaddrinfo getnameinf +o); use if $] >= 5.014, "Socket" => qw(:addrinfo inet_ntoa inet_ntop unpac +k_sockaddr_in unpack_sockaddr_in6 IPPROTO_TCP AF_INET AF_UNSPEC);

    If you want your program to run on both Windows and Linux, good luck. Socket does have IPv6 support on Linux. With Windows, it appears the headers and libraries supplied with Strawberry's C compiler don't have the IPv6 routines (get*info); however, they ARE available on Windows and I've compiled C programs that use them. I'm guessing Strawberry Perl gcc compiler (headers and libraries) need to be updated and the Socket module recompiled as Windows 7 will support it, but not in the current Strawberry distribution (I'm running 5.12.3, but have also tested with 5.14).

    UPDATE: See UPDATE section in Re^2: ipv6 support on windows.

      Thank you for the insights.

      Ultimately, I do need to cover Windows and *NIX so it makes a huge amount of sense to develop using the new getaddrinfo() in Perl Core.

      I'm not that interested in messing around with Socket6 or Socket::GetAddrInfo and trying to build them on Windoze.

      Unfortunately, the *NIX boxes I currently have access to are not yet IPv6 ready so I tried to start work using a Win 7 machine that is. But at this point, I'm inclined to try and build a Linux box with IPv6 and proceed using that as my development platform. Hopefully ActivePerl and/or Strawberry Perl on Windows will catch up in the fullness of time.

        You may want to take a look at AnyEvent::Socket. It's not quite the same, as it includes it's own DNS layer, bypassing system libraries.

        Well, I threw Ubuntu on an old laptop, added IPv6, and have Perl talking to a IPv6-only server. This will allow me to proceed with development using a sound platform.

        I do hope ActiveState can fix ActivePerl on Windows before too long.

Re: Perl and IPv6 on Windows
by Anonymous Monk on Jul 05, 2012 at 16:15 UTC

      Socket6 may or may not work but it's certainly not a robust solution for the long term. The IPv6 features of Socket6 were (at least in theory) moved to the Core Socket module at Perl 5.14.

      http://www.perl.org/about/whitepapers/perl-ipv6.html