Skip to content

Commit

Permalink
cpan/IO-Socket-IP - Update to version 0.43
Browse files Browse the repository at this point in the history
0.43    2024-11-25
        [CHANGES]
         * Swapped unit tests from `Test::More` to `Test2::V0`
         * Fixed some documentation typoes
           (thanks Igor Sobrado Delgado) (RT157201)

co-authored-by: Eric Herman <[email protected]>
co-authored-by: Philippe Bruhat (BooK) <[email protected]>
  • Loading branch information
3 people committed Dec 5, 2024
1 parent a3319b9 commit 00f06a3
Show file tree
Hide file tree
Showing 25 changed files with 129 additions and 121 deletions.
4 changes: 2 additions & 2 deletions Porting/Maintainers.pl
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ package Maintainers;
},

'IO::Socket::IP' => {
'DISTRIBUTION' => 'PEVANS/IO-Socket-IP-0.42.tar.gz',
'SYNCINFO' => 'jkeenan on Wed Aug 16 21:34:20 2023',
'DISTRIBUTION' => 'PEVANS/IO-Socket-IP-0.43.tar.gz',
'SYNCINFO' => 'tib on Wed Dec 4 17:32:19 2024',
'FILES' => q[cpan/IO-Socket-IP],
'EXCLUDED' => [
qr{^examples/},
Expand Down
54 changes: 30 additions & 24 deletions cpan/IO-Socket-IP/lib/IO/Socket/IP.pm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# You may distribute under the terms of either the GNU General Public License
# or the Artistic License (the same terms as Perl itself)
#
# (C) Paul Evans, 2010-2023 -- [email protected]
# (C) Paul Evans, 2010-2024 -- [email protected]

package IO::Socket::IP 0.42;
package IO::Socket::IP 0.43;

use v5.14;
use warnings;
Expand Down Expand Up @@ -64,6 +64,8 @@ C<IO::Socket::IP> - Family-neutral IP socket supporting both IPv4 and IPv6
=head1 SYNOPSIS
=for highlighter language=perl
use IO::Socket::IP;
my $sock = IO::Socket::IP->new(
Expand All @@ -83,7 +85,7 @@ C<IO::Socket::IP> - Family-neutral IP socket supporting both IPv4 and IPv6
This module provides a protocol-independent way to use IPv4 and IPv6 sockets,
intended as a replacement for L<IO::Socket::INET>. Most constructor arguments
and methods are provided in a backward-compatible way. For a list of known
differences, see the C<IO::Socket::INET> INCOMPATIBILITES section below.
differences, see the C<IO::Socket::INET> INCOMPATIBILITIES section below.
It uses the C<getaddrinfo(3)> function to convert hostnames and service names
or port numbers into sets of possible addresses to connect to or listen on.
Expand Down Expand Up @@ -313,7 +315,7 @@ two listening sockets, one bound to each protocol.
=item MultiHomed
This C<IO::Socket::INET>-style argument is ignored, except if it is defined
but false. See the C<IO::Socket::INET> INCOMPATIBILITES section below.
but false. See the C<IO::Socket::INET> INCOMPATIBILITIES section below.
However, the behaviour it enables is always performed by C<IO::Socket::IP>.
Expand Down Expand Up @@ -348,7 +350,7 @@ recognised are ignored.
If neither C<Family> nor any hosts or addresses are passed, nor any
C<*AddrInfo>, then the constructor has no information on which to decide a
socket family to create. In this case, it performs a C<getaddinfo> call with
socket family to create. In this case, it performs a C<getaddrinfo> call with
the C<AI_ADDRCONFIG> flag, no host name, and a service name of C<"0">, and
uses the family of the first returned result.
Expand Down Expand Up @@ -827,7 +829,7 @@ sub _unpack_sockaddr

=head2 sockhost_service
( $host, $service ) = $sock->sockhost_service( $numeric )
( $host, $service ) = $sock->sockhost_service( $numeric );
Returns the hostname and service name of the local address (that is, the
socket address given by the C<sockname> method).
Expand All @@ -852,25 +854,25 @@ sub sockhost_service

=head2 sockhost
$addr = $sock->sockhost
$addr = $sock->sockhost;
Return the numeric form of the local address as a textual representation
=head2 sockport
$port = $sock->sockport
$port = $sock->sockport;
Return the numeric form of the local port number
=head2 sockhostname
$host = $sock->sockhostname
$host = $sock->sockhostname;
Return the resolved name of the local address
=head2 sockservice
$service = $sock->sockservice
$service = $sock->sockservice;
Return the resolved name of the local port number
Expand All @@ -884,7 +886,7 @@ sub sockservice { my $self = shift; scalar +( $self->_get_host_service( $self->

=head2 sockaddr
$addr = $sock->sockaddr
$addr = $sock->sockaddr;
Return the local address as a binary octet string
Expand All @@ -894,7 +896,7 @@ sub sockaddr { my $self = shift; _unpack_sockaddr $self->sockname }

=head2 peerhost_service
( $host, $service ) = $sock->peerhost_service( $numeric )
( $host, $service ) = $sock->peerhost_service( $numeric );
Returns the hostname and service name of the peer address (that is, the
socket address given by the C<peername> method), similar to the
Expand All @@ -917,25 +919,25 @@ sub peerhost_service

=head2 peerhost
$addr = $sock->peerhost
$addr = $sock->peerhost;
Return the numeric form of the peer address as a textual representation
=head2 peerport
$port = $sock->peerport
$port = $sock->peerport;
Return the numeric form of the peer port number
=head2 peerhostname
$host = $sock->peerhostname
$host = $sock->peerhostname;
Return the resolved name of the peer address
=head2 peerservice
$service = $sock->peerservice
$service = $sock->peerservice;
Return the resolved name of the peer port number
Expand All @@ -949,7 +951,7 @@ sub peerservice { my $self = shift; scalar +( $self->_get_host_service( $self->

=head2 peeraddr
$addr = $peer->peeraddr
$addr = $peer->peeraddr;
Return the peer address as a binary octet string
Expand Down Expand Up @@ -1001,7 +1003,7 @@ BEGIN {

=head2 as_inet
$inet = $sock->as_inet
$inet = $sock->as_inet;
Returns a new L<IO::Socket::INET> instance wrapping the same filehandle. This
may be useful in cases where it is required, for backward-compatibility, to
Expand Down Expand Up @@ -1060,7 +1062,7 @@ called in a child process.
use IO::Socket::IP;
use Errno qw( EINPROGRESS EWOULDBLOCK );
my @peeraddrinfo = ... # Caller must obtain the getaddinfo result here
my @peeraddrinfo = ... # Caller must obtain the getaddrinfo result here
my $socket = IO::Socket::IP->new(
PeerAddrInfo => \@peeraddrinfo,
Expand Down Expand Up @@ -1103,10 +1105,14 @@ of the following special forms then special parsing is applied.
The value of the C<...Host> argument will be split to give both the hostname
and port (or service name):
=for highlighter
hostname.example.org:http # Host name
192.0.2.1:80 # IPv4 address
[2001:db8::1]:80 # IPv6 address
=for highlighter language=perl
In each case, the port or service name (e.g. C<80>) is passed as the
C<LocalService> or C<PeerService> argument.
Expand All @@ -1132,16 +1138,16 @@ Returns a 2-element list, containing either the split hostname and port
description if it could be parsed, or the given address and C<undef> if it was
not recognised.
IO::Socket::IP->split_addr( "hostname:http" )
IO::Socket::IP->split_addr( "hostname:http" );
# ( "hostname", "http" )
IO::Socket::IP->split_addr( "192.0.2.1:80" )
IO::Socket::IP->split_addr( "192.0.2.1:80" );
# ( "192.0.2.1", "80" )
IO::Socket::IP->split_addr( "[2001:db8::1]:80" )
IO::Socket::IP->split_addr( "[2001:db8::1]:80" );
# ( "2001:db8::1", "80" )
IO::Socket::IP->split_addr( "something.else" )
IO::Socket::IP->split_addr( "something.else" );
# ( "something.else", undef )
=cut
Expand Down Expand Up @@ -1219,7 +1225,7 @@ sub configure
$self->configure( { %$arg, Family => Socket::AF_INET6() } );
}

=head1 C<IO::Socket::INET> INCOMPATIBILITES
=head1 C<IO::Socket::INET> INCOMPATIBILITIES
=over 4
Expand Down
5 changes: 3 additions & 2 deletions cpan/IO-Socket-IP/t/00use.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
use v5.14;
use warnings;

use Test::More;
use Test2::V0;

use_ok( "IO::Socket::IP" );
require IO::Socket::IP;

pass( 'Modules loaded' );
done_testing;
14 changes: 7 additions & 7 deletions cpan/IO-Socket-IP/t/01local-client-v4.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use v5.14;
use warnings;

use Test::More;
use Test2::V0;

use IO::Socket::IP;

Expand Down Expand Up @@ -52,13 +52,13 @@ foreach my $socktype (qw( SOCK_STREAM SOCK_DGRAM )) {
ok( $socket->connected, "\$socket is connected for $socktype" );
ok( $socket->blocking, "\$socket is in blocking mode after connect for $socktype" );

is_deeply( [ unpack_sockaddr_in $socket->sockname ],
[ unpack_sockaddr_in $testclient->peername ],
"\$socket->sockname for $socktype" );
is( [ unpack_sockaddr_in $socket->sockname ],
[ unpack_sockaddr_in $testclient->peername ],
"\$socket->sockname for $socktype" );

is_deeply( [ unpack_sockaddr_in $socket->peername ],
[ unpack_sockaddr_in $testclient->sockname ],
"\$socket->peername for $socktype" );
is( [ unpack_sockaddr_in $socket->peername ],
[ unpack_sockaddr_in $testclient->sockname ],
"\$socket->peername for $socktype" );

is( $socket->peerhost, $INADDR_LOOPBACK_HOST, "\$socket->peerhost for $socktype" );
is( $socket->peerport, $testserver->sockport, "\$socket->peerport for $socktype" );
Expand Down
20 changes: 10 additions & 10 deletions cpan/IO-Socket-IP/t/02local-server-v4.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use v5.14;
use warnings;

use Test::More;
use Test2::V0;

use IO::Socket::IP;

Expand Down Expand Up @@ -43,8 +43,8 @@ foreach my $socktype (qw( SOCK_STREAM SOCK_DGRAM )) {
ok( eval { $testserver->peerport; 1 }, "\$testserver->peerport does not die for $socktype" )
or do { chomp( my $e = $@ ); diag( "Exception was: $e" ) };

is_deeply( { host => $testserver->peerhost, port => $testserver->peerport },
{ host => undef, port => undef },
is( { host => $testserver->peerhost, port => $testserver->peerport },
{ host => undef, port => undef },
'peerhost/peersock yield scalar' );

my $socket = IO::Socket::INET->new(
Expand All @@ -59,18 +59,18 @@ foreach my $socktype (qw( SOCK_STREAM SOCK_DGRAM )) {
do { $testserver->connect( $socket->sockname ); $testserver };

ok( defined $testclient, "accepted test $socktype client" );
isa_ok( $testclient, "IO::Socket::IP", "\$testclient for $socktype" );
isa_ok( $testclient, [ "IO::Socket::IP" ], "\$testclient for $socktype" );

is( $testclient->sockdomain, AF_INET, "\$testclient->sockdomain for $socktype" );
is( $testclient->socktype, Socket->$socktype, "\$testclient->socktype for $socktype" );

is_deeply( [ unpack_sockaddr_in $socket->sockname ],
[ unpack_sockaddr_in $testclient->peername ],
"\$socket->sockname for $socktype" );
is( [ unpack_sockaddr_in $socket->sockname ],
[ unpack_sockaddr_in $testclient->peername ],
"\$socket->sockname for $socktype" );

is_deeply( [ unpack_sockaddr_in $socket->peername ],
[ unpack_sockaddr_in $testclient->sockname ],
"\$socket->peername for $socktype" );
is( [ unpack_sockaddr_in $socket->peername ],
[ unpack_sockaddr_in $testclient->sockname ],
"\$socket->peername for $socktype" );

is( $testclient->sockport, $socket->peerport, "\$testclient->sockport for $socktype" );
is( $testclient->peerport, $socket->sockport, "\$testclient->peerport for $socktype" );
Expand Down
2 changes: 1 addition & 1 deletion cpan/IO-Socket-IP/t/03local-cross-v4.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use v5.14;
use warnings;

use Test::More;
use Test2::V0;

use IO::Socket::IP;

Expand Down
14 changes: 7 additions & 7 deletions cpan/IO-Socket-IP/t/04local-client-v6.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use v5.14;
use warnings;

use Test::More;
use Test2::V0;

use IO::Socket::IP;
use Socket qw( inet_pton inet_ntop pack_sockaddr_in6 unpack_sockaddr_in6 IN6ADDR_LOOPBACK );
Expand Down Expand Up @@ -66,13 +66,13 @@ foreach my $socktype (qw( SOCK_STREAM SOCK_DGRAM )) {

ok( $socket->connected, "\$socket is connected for $socktype" );

is_deeply( [ unpack_sockaddr_in6_addrport( $socket->sockname ) ],
[ unpack_sockaddr_in6_addrport( $testclient->peername ) ],
"\$socket->sockname for $socktype" );
is( [ unpack_sockaddr_in6_addrport( $socket->sockname ) ],
[ unpack_sockaddr_in6_addrport( $testclient->peername ) ],
"\$socket->sockname for $socktype" );

is_deeply( [ unpack_sockaddr_in6_addrport( $socket->peername ) ],
[ unpack_sockaddr_in6_addrport( $testclient->sockname ) ],
"\$socket->peername for $socktype" );
is( [ unpack_sockaddr_in6_addrport( $socket->peername ) ],
[ unpack_sockaddr_in6_addrport( $testclient->sockname ) ],
"\$socket->peername for $socktype" );

is( $socket->peerhost, $IN6ADDR_LOOPBACK_HOST, "\$socket->peerhost for $socktype" );
is( $socket->peerport, $testport, "\$socket->peerport for $socktype" );
Expand Down
16 changes: 8 additions & 8 deletions cpan/IO-Socket-IP/t/05local-server-v6.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use v5.14;
use warnings;

use Test::More;
use Test2::V0;

use IO::Socket::IP;
use Socket qw( inet_pton inet_ntop pack_sockaddr_in6 unpack_sockaddr_in6 IN6ADDR_LOOPBACK );
Expand Down Expand Up @@ -64,18 +64,18 @@ foreach my $socktype (qw( SOCK_STREAM SOCK_DGRAM )) {
do { $testserver->connect( $socket->sockname ); $testserver };

ok( defined $testclient, "accepted test $socktype client" );
isa_ok( $testclient, "IO::Socket::IP", "\$testclient for $socktype" );
isa_ok( $testclient, [ "IO::Socket::IP" ], "\$testclient for $socktype" );

is( $testclient->sockdomain, $AF_INET6, "\$testclient->sockdomain for $socktype" );
is( $testclient->socktype, Socket->$socktype, "\$testclient->socktype for $socktype" );

is_deeply( [ unpack_sockaddr_in6_addrport( $socket->sockname ) ],
[ unpack_sockaddr_in6_addrport( $testclient->peername ) ],
"\$socket->sockname for $socktype" );
is( [ unpack_sockaddr_in6_addrport( $socket->sockname ) ],
[ unpack_sockaddr_in6_addrport( $testclient->peername ) ],
"\$socket->sockname for $socktype" );

is_deeply( [ unpack_sockaddr_in6_addrport( $socket->peername ) ],
[ unpack_sockaddr_in6_addrport( $testclient->sockname ) ],
"\$socket->peername for $socktype" );
is( [ unpack_sockaddr_in6_addrport( $socket->peername ) ],
[ unpack_sockaddr_in6_addrport( $testclient->sockname ) ],
"\$socket->peername for $socktype" );

my $peerport = ( Socket::unpack_sockaddr_in6 $socket->peername )[0];
my $sockport = ( Socket::unpack_sockaddr_in6 $socket->sockname )[0];
Expand Down
2 changes: 1 addition & 1 deletion cpan/IO-Socket-IP/t/06local-cross-v6.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use v5.14;
use warnings;

use Test::More;
use Test2::V0;

use IO::Socket::IP;

Expand Down
Loading

0 comments on commit 00f06a3

Please sign in to comment.