Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

How to require IPv6 support

by mbethke (Hermit)
on Aug 01, 2012 at 17:11 UTC ( #984838=perlquestion: print w/ replies, xml ) Need Help??
mbethke has asked for the wisdom of the Perl Monks concerning the following question:

I've just extended my Net::CIDR::Lookup module with an IPv6 version and am seeing a lot of failed tests form CPANtesters. Clearly an oversight: I just assumed Socket would nowadays always export unpack_sockaddr_in6 and the like. This needs fixing but there's two things I'm not clear about:

  1. Is there a halfway easy way nowadays to find the oldest version of a module that supports a certain feature in the first place? Searching around here I found a half-decade-old thread that mentions it's a tedious process, but I knew that already :) Basically bisecting one's way through every version on BackPAN should be rather straightforward, maybe someone has written some code for it already?
  2. Now I think the IPv6-Socket problem may even be a bit more complicated as e.g. unpack_sockaddr_in6 will only actually be functional if the system had IPv6 support at XS compile time, otherwise it's there but croaks when called. I'm quite sure ExtUtils::MakeMaker has no way of checking a prerequisite for anything else but a version number, but maybe something like Module::Build does? I haven't found anything like it in the docs but I suppose something like this would make sense---a sub instead of a version that just returns a boolean indicating whether the installed version is acceptable:
    PREREQ_PM => { 'Bit::Vector' => 0, Socket => sub { eval { Socket::unpack_sockaddr_in6("\xa".("\0"x22)."\x01\0\0\ +0\0"); 1; } or do { $@ and return 0; } } },

Comment on How to require IPv6 support
Select or Download Code
Re: How to require IPv6 support
by Anonymous Monk on Aug 01, 2012 at 21:54 UTC

      Nice, I hadn't seen that repo's web interface yet! That's a solution for core modules at least, but I still have the problem under (2) that even though it's the latest version it may not work.

      For now I think I'll work around it by simply skipping the corresponding tests and noting in the docs that you must have an IPv6-enabled Socket module to use this, but it would be nice to be able top specify this in a Module::* installer.

        For now I think I'll work around it by simply skipping the corresponding tests and noting in the docs that you must have an IPv6-enabled Socket module to use this,

        Sounds like the common practice :)

        but it would be nice to be able top specify this in a Module::* installer.

        Hmm, so a patch to Module::Depends - identify the dependencies of a distribution

        and a patch to Module::Install#requires

        So you end up with

        requires qw' Socket 2 unpack_sockaddr_in6 '; # requires qw' Socket 2 Socket::unpack_sockaddr_in6 ';

        That could work, and doesn't look particularly hard to implement.

Re: How to require IPv6 support
by VinsWorldcom (Priest) on Aug 02, 2012 at 11:27 UTC

    You'll see fails for Win32 with Perl certainly less than 5.14. I know for a fact the Strawberry < 5.14 versions of Socket do not support IPv6 as I've tried with them on Windows 7 which certainly does support IPv6 and will compile IPv6 C code.

    The work around I've used is:

    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);
    UPDATE: See UPDATE section in Re^2: ipv6 support on windows.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://984838]
Approved by marto
Front-paged by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2014-11-28 14:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (197 votes), past polls