Subject: | Handling of PeerPort incompatible with IO::Socket::INET |
If IO::Socket::INET receives both a PeerAddr with port information and
PeerPort, it ignores the value of PeerPort and extracts the port from
PeerAddr. IO::Socket::IP returns an error. Attached is a script that
demonstrates the problem.
Doubt this is worth fixing, but maybe this ticket will save someone a
dive through the socket code. This was only an issue for me due to a
bizarre set of circumstances (changed the backing IO::Socket of
Net::POP3 which always supplies PeerPort).
Subject: | error.pl |
use threads;
use IO::Socket::INET;
use IO::Socket::IP;
sub monitor_port {
my ($port) = @_;
my $local = IO::Socket::INET->new(
LocalPort => $port,
Listen => 1,
Proto => 'tcp',
);
my $peer,$addr;
while( $peer = $local->accept ) {
printf STDERR "Received connection on %d: %s:%d\n",
$port, $peer->peerhost, $peer->peerport;
$peer->close;
}
}
threads->create( \&monitor_port, 2000 );
threads->create( \&monitor_port, 3000 );
print STDERR "IO::Socket::INET\n";
IO::Socket::INET->new(
PeerAddr => '127.0.0.1:2000',
PeerPort => 3000,
) or die $!;
print STDERR "IO::Socket::IP\n";
IO::Socket::IP->new(
PeerAddr => '127.0.0.1:2000',
PeerPort => 3000,
) or die $!;