Net::Server::IP(3)

NAME
Net::Server::IP - IPv4 / IPv6 compatibility module

SYNOPSIS
    use Net::Server::IP;

    my $sock = Net::Server::IP->new(
        LocalAddr => "[::]",
        LocalPort => 8080,
        Listen => 1,
    ) or die "IPv6 listen error: $@ $!";

    my $sock = Net::Server::IP->new(
        PeerAddr => "[::1]:8080",
    ) or die "IPv6 connect error: $@ $!";

    my $sock = Net::Server::IP->new(
        PeerAddr => "127.0.0.1:8080",
    ) or die "IPv4 connect error: $@ $!";

DESCRIPTION
In order to support IPv6, Net::Server:IP inherits from either IO::Socket::IP or IO::Socket::INET6, whichever is available. This provides a consistent convention regardless of any differences between these modules. If only IPv4 is required based on its parameters, then neither module needs to be installed. Everything will still work fine by only inheriting from IO::Socket::INET. IO::Socket::IP will take preference, if available. To override this default behavior:

    $Net::Server::IP::ipv6_package = 'Custom::Mod::Handle';

INPUTS

  $sock = Net::Server::IP->new( %args )
Creates a new "Net::Server::IP" handle object. The arguments recognized are similar to "IO::Socket::IP" or "IO::Socket::INET6". If the constructor fails, check $@ for the error message.

Special consideration applies to the following parameters:

Family => INT (like "IO::Socket::IP")
Domain => INT (like "IO::Socket::INET6")
    Address family for the socket. (e.g. "AF_INET", "AF_INET6") "Domain" is synonym for "Family". Both args are the same. "Family" will take precedence if both are supplied.

    If provided, this will be used to determine if IPv6 is required.

LocalHost => STRING
LocalAddr => STRING
PeerHost => STRING
PeerAddr => STRING
    Hostname with optional Port. If "Family" is not provided, then this will be scanned as a hint for which "Family" to use.

GetAddrInfoFlags => INT
    Normally with IO::Socket::IP, GetAddrInfoFlags will default this to Socket::AI_ADDRCONFIG. But this can cause problems on certain legacy emulation platforms, such as the OpenVZ spoofed venet and loopback interface. In such cases, GetAddrInfoFlags will default to 0 instead.

V6Only => BOOL
    With IO::Socket::IP nothing will change. IO::Socket::INET6 normally ignores V6Only, so to make the convention consistent, now the same functionality will just work. So even if IO::Socket::IP is not installed, the V6Only option will be emulated with IO::Socket::INET6.

    If V6Only is true, then IPv4 sockets will not work on this handle. Set V6Only to 0 to enable Dual-Stack sockets to support IPv4-mapped IPv6 addresses (i.e., ::ffff:127.0.0.1) within the same handle. If V6Only is not set or is undef, then the Dual-Stack behavior will be whatever the Operating System default is. To avoid expected behaviors across different platforms, the V6Only arg should always be explicitly set (i.e., 0 or 1) rather than letting the OS choose.

AUTHOR
Paul Seamons <paul@seamons.com>

Rob Brown <bbb@cpan.org>

SEE ALSO
IO::Socket::IP, IO::Socket::INET, IO::Socket::INET6

LICENSE
Distributed under the same terms as Net::Server