Perl supports IPv6

Perl and IPv6 support

Perl and IPv6 - Perl supports IPv6

How to use both IPv4 and IPv6 networks from Perl

To enable IPv6 in Perl, replace any use of IO::Socket::INET with IO::Socket::IP and you will be able to use both IPv4 and IPv6. Perl 5.14 has the full set of IPv6 functions as part of its core Socket module.

The Perl community is currently in the process of converting older modules to use this. If you use a module which has not been converted please report it to the module author.

The IO::Socket::IP class provides a general-purpose socket that can provide TCP connections or UDP packets using either IPv4 or IPv6. It is an API-compatible replacement for its IPv4-only predecessor, IO::Socket::INET.

IO::Socket::IP should be a direct drop-in replacement for IO::Socket::INET. It supports the same constructor arguments and the same methods as IO::Socket::INET, most programs only need to change the 'use' line and constructor calls, allowing them to support IPv6.

Unfortunately IO::Socket::INET could not be upgraded in such a way that would not cause backwards incompatibilities; existing code may expect IO::Socket::INET to always return IPv4 sockets.

Perl 5.14 ships with a complete set of IPv6-related functions in the Socket module. It provides the AF_INET6 constant, sockaddr_in6 address structure handling functions, and the getaddrinfo and getnameinfo functions. IO::Socket::IP uses these on Perl 5.14, making it an easy install requiring no other modules, nor compiling any XS code.

On versions of Perl before 5.14, IO::Socket::IP needs a newer version of Socket to provide the IP protocol-neutral support, by way of the getaddrinfo and getnameinfo functions. This is available on CPAN and requires XS code to build.


Article Authors

Paul "LeoNerd" Evans and Leo Lapworth