Permalink
Browse files

make the ipv6 stuff confess if it isnt available

  • Loading branch information...
apocalypse committed Apr 20, 2011
1 parent 88bae38 commit a12120d1e6af19c419b5ef299c3bffcedc652b0d
Showing with 16 additions and 12 deletions.
  1. +12 −6 lib/POE/Component/Server/TCP.pm
  2. +4 −6 lib/POE/Wheel/SocketFactory.pm
@@ -9,6 +9,13 @@ use Carp qw(carp croak);
use Socket qw(INADDR_ANY inet_ntoa inet_aton AF_INET AF_UNIX PF_UNIX);
use Errno qw(ECONNABORTED ECONNRESET);
+BEGIN {
+ eval "use Socket::GetAddrInfo qw(:newapi getaddrinfo)";
+ if ($@) {
+ *getaddrinfo = sub { Carp::confess("Unable to use IPv6: Socket::GetAddrInfo not available") };
+ }
+}
+
# Explicit use to import the parameter constants.
use POE::Session;
use POE::Driver::SysRW;
@@ -274,9 +281,7 @@ sub new {
$heap->{remote_ip} = inet_ntoa($remote_addr);
}
else {
- $heap->{remote_ip} = (
- Socket::GetAddrInfo::getaddrinfo($remote_addr)
- )[1];
+ $heap->{remote_ip} = ( getaddrinfo($remote_addr) )[1];
}
$heap->{remote_port} = $remote_port;
@@ -937,9 +942,10 @@ C<Domain> sets the address or protocol family within which to operate.
The C<Domain> may be any value that POE::Wheel::SocketFactory
supports. AF_INET (Internet address space) is used by default.
-Use AF_INET6 for IPv6 support. This constant is exported by Socket.
-Also be sure to have Socket::GetAddrInfo installed, which is required
-by POE::Wheel::SocketFactory for IPv6 support.
+Use AF_INET6 for IPv6 support. This constant is exported by L<Socket>
+or L<Socket6>, depending on your version of Perl. Also be sure to have
+L<Socket::GetAddrInfo> installed, which is required by
+L<POE::Wheel::SocketFactory> for IPv6 support.
=head4 Error
@@ -53,10 +53,8 @@ sub MY_SOCKET_SELECTED () { 12 }
BEGIN {
eval "use Socket::GetAddrInfo qw(:newapi getaddrinfo getnameinfo)";
if ($@) {
- my $why = $@;
- $why =~ s/ at \(eval.* line \d+\.\s*//;
- *getaddrinfo = sub { return "Socket::GetAddrInfo not loaded: $why" };
- *getnameinfo = sub { return "Socket::GetAddrInfo not loaded: $why" };
+ *getaddrinfo = sub { Carp::confess("Unable to use IPv6: Socket::GetAddrInfo not available") };
+ *getnameinfo = sub { Carp::confess("Unable to use IPv6: Socket::GetAddrInfo not available") };
}
# Socket6 provides AF_INET6 and PF_INET6 where earlier Perls' Socket don't.
@@ -69,15 +67,15 @@ BEGIN {
if ($@) {
eval { require Socket6; Socket6->import('AF_INET6') };
if ($@) {
- *AF_INET6 = sub { ~0 };
+ *AF_INET6 = sub { Carp::confess("Unable to use IPv6: Socket6 not available") };
}
}
eval { require Socket; Socket->import('PF_INET6') };
if ($@) {
eval { require Socket6; Socket6->import('PF_INET6') };
if ($@) {
- *PF_INET6 = sub { ~0 };
+ *PF_INET6 = sub { Carp::confess("Unable to use IPv6: Socket6 not available") };
}
}
}

0 comments on commit a12120d

Please sign in to comment.