Net::Server::IP(3)
π NAME
Net::Server::IP β bestie, it's the IPv4 / IPv6 compatibility module, and it just works either way π¦
β¨ 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: $@ $!";
No cap, those three snippets are literally the whole personality of this module πΈ
π DESCRIPTION
Okay so real talk: to support IPv6, Net::Server::IP inherits from either IO::Socket::IP or IO::Socket::INET6, whichever one is available. The whole point is you get a consistent convention no matter what weird little differences those modules have between them π«Ά
And here's the iconic part: if your parameters mean you only need IPv4, then neither of those modules needs to be installed at all. Everything still works fine just inheriting from IO::Socket::INET. Slay π
IO::Socket::IP will take preference, if available. And if you want to override that default behavior:
$Net::Server::IP::ipv6_package = 'Custom::Mod::Handle';
Periodt. That's your escape hatch π
π₯ INPUTS
$sock = Net::Server::IP->new( %args )
Creates a new Net::Server::IP handle object β¨ The arguments it recognizes are similar to IO::Socket::IP or IO::Socket::INET6. And if the constructor fails? Check $@ for the error message, bestie β that's where the tea is π
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).
Domainis a synonym forFamily. Both args are literally the same thing.Familywill 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. Sneaky but helpful.
GetAddrInfoFlags => INT
Normally with IO::Socket::IP, GetAddrInfoFlags will default this to Socket::AI_ADDRCONFIG. But β plot twist β that 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. Not a bug, just the vibe of those platforms.
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
V6Onlyis true, then IPv4 sockets will not work on this handle π - Set
V6Onlyto0to enable Dual-Stack sockets to support IPv4-mapped IPv6 addresses (i.e.,::ffff:127.0.0.1) within the same handle π - If
V6Onlyis not set or isundef, then the Dual-Stack behavior will be whatever the Operating System default is.
Bestie, listen: to avoid expected behaviors across different platforms, theV6Onlyarg should always be explicitly set (i.e.,0or1) rather than letting the OS choose. Do not let the OS make this decision for you, it's giving chaos energy π
π§ AUTHOR
- Paul Seamons
<paul@seamons.com> - Rob Brown
<bbb@cpan.org>
Legends, honestly π
π¦ SEE ALSO
IO::Socket::IP, IO::Socket::INET, IO::Socket::INET6 β go read those too, iykyk π
πΈ LICENSE
Distributed under the same terms as Net::Server.
That's the whole page, bestie! π This was perl v5.42.2 and the date on the tin is 2026-02-27 β go forth and bind responsibly, mwah πβ¨
π¦ where this page comes from
- alpine 3.24: perl-net-server-doc 2.018-r0 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms