1
1
# You may distribute under the terms of either the GNU General Public License
2
2
# or the Artistic License (the same terms as Perl itself)
3
3
#
4
- # (C) Paul Evans, 2010-2023 -- leonerd@leonerd.org.uk
4
+ # (C) Paul Evans, 2010-2024 -- leonerd@leonerd.org.uk
5
5
6
- package IO::Socket::IP 0.42 ;
6
+ package IO::Socket::IP 0.43 ;
7
7
8
8
use v5.14;
9
9
use warnings;
@@ -64,6 +64,8 @@ C<IO::Socket::IP> - Family-neutral IP socket supporting both IPv4 and IPv6
64
64
65
65
=head1 SYNOPSIS
66
66
67
+ =for highlighter language=perl
68
+
67
69
use IO::Socket::IP;
68
70
69
71
my $sock = IO::Socket::IP->new(
@@ -83,7 +85,7 @@ C<IO::Socket::IP> - Family-neutral IP socket supporting both IPv4 and IPv6
83
85
This module provides a protocol-independent way to use IPv4 and IPv6 sockets,
84
86
intended as a replacement for L<IO::Socket::INET> . Most constructor arguments
85
87
and methods are provided in a backward-compatible way. For a list of known
86
- differences, see the C<IO::Socket::INET > INCOMPATIBILITES section below.
88
+ differences, see the C<IO::Socket::INET > INCOMPATIBILITIES section below.
87
89
88
90
It uses the C<getaddrinfo(3) > function to convert hostnames and service names
89
91
or port numbers into sets of possible addresses to connect to or listen on.
@@ -313,7 +315,7 @@ two listening sockets, one bound to each protocol.
313
315
=item MultiHomed
314
316
315
317
This C<IO::Socket::INET > -style argument is ignored, except if it is defined
316
- but false. See the C<IO::Socket::INET > INCOMPATIBILITES section below.
318
+ but false. See the C<IO::Socket::INET > INCOMPATIBILITIES section below.
317
319
318
320
However, the behaviour it enables is always performed by C<IO::Socket::IP > .
319
321
@@ -348,7 +350,7 @@ recognised are ignored.
348
350
349
351
If neither C<Family > nor any hosts or addresses are passed, nor any
350
352
C<*AddrInfo > , then the constructor has no information on which to decide a
351
- socket family to create. In this case, it performs a C<getaddinfo > call with
353
+ socket family to create. In this case, it performs a C<getaddrinfo > call with
352
354
the C<AI_ADDRCONFIG > flag, no host name, and a service name of C<"0" > , and
353
355
uses the family of the first returned result.
354
356
@@ -827,7 +829,7 @@ sub _unpack_sockaddr
827
829
828
830
=head2 sockhost_service
829
831
830
- ( $host, $service ) = $sock->sockhost_service( $numeric )
832
+ ( $host, $service ) = $sock->sockhost_service( $numeric );
831
833
832
834
Returns the hostname and service name of the local address (that is, the
833
835
socket address given by the C<sockname > method).
@@ -852,25 +854,25 @@ sub sockhost_service
852
854
853
855
=head2 sockhost
854
856
855
- $addr = $sock->sockhost
857
+ $addr = $sock->sockhost;
856
858
857
859
Return the numeric form of the local address as a textual representation
858
860
859
861
=head2 sockport
860
862
861
- $port = $sock->sockport
863
+ $port = $sock->sockport;
862
864
863
865
Return the numeric form of the local port number
864
866
865
867
=head2 sockhostname
866
868
867
- $host = $sock->sockhostname
869
+ $host = $sock->sockhostname;
868
870
869
871
Return the resolved name of the local address
870
872
871
873
=head2 sockservice
872
874
873
- $service = $sock->sockservice
875
+ $service = $sock->sockservice;
874
876
875
877
Return the resolved name of the local port number
876
878
@@ -884,7 +886,7 @@ sub sockservice { my $self = shift; scalar +( $self->_get_host_service( $self->
884
886
885
887
=head2 sockaddr
886
888
887
- $addr = $sock->sockaddr
889
+ $addr = $sock->sockaddr;
888
890
889
891
Return the local address as a binary octet string
890
892
@@ -894,7 +896,7 @@ sub sockaddr { my $self = shift; _unpack_sockaddr $self->sockname }
894
896
895
897
=head2 peerhost_service
896
898
897
- ( $host, $service ) = $sock->peerhost_service( $numeric )
899
+ ( $host, $service ) = $sock->peerhost_service( $numeric );
898
900
899
901
Returns the hostname and service name of the peer address (that is, the
900
902
socket address given by the C<peername > method), similar to the
@@ -917,25 +919,25 @@ sub peerhost_service
917
919
918
920
=head2 peerhost
919
921
920
- $addr = $sock->peerhost
922
+ $addr = $sock->peerhost;
921
923
922
924
Return the numeric form of the peer address as a textual representation
923
925
924
926
=head2 peerport
925
927
926
- $port = $sock->peerport
928
+ $port = $sock->peerport;
927
929
928
930
Return the numeric form of the peer port number
929
931
930
932
=head2 peerhostname
931
933
932
- $host = $sock->peerhostname
934
+ $host = $sock->peerhostname;
933
935
934
936
Return the resolved name of the peer address
935
937
936
938
=head2 peerservice
937
939
938
- $service = $sock->peerservice
940
+ $service = $sock->peerservice;
939
941
940
942
Return the resolved name of the peer port number
941
943
@@ -949,7 +951,7 @@ sub peerservice { my $self = shift; scalar +( $self->_get_host_service( $self->
949
951
950
952
=head2 peeraddr
951
953
952
- $addr = $peer->peeraddr
954
+ $addr = $peer->peeraddr;
953
955
954
956
Return the peer address as a binary octet string
955
957
@@ -1001,7 +1003,7 @@ BEGIN {
1001
1003
1002
1004
=head2 as_inet
1003
1005
1004
- $inet = $sock->as_inet
1006
+ $inet = $sock->as_inet;
1005
1007
1006
1008
Returns a new L<IO::Socket::INET> instance wrapping the same filehandle. This
1007
1009
may be useful in cases where it is required, for backward-compatibility, to
@@ -1060,7 +1062,7 @@ called in a child process.
1060
1062
use IO::Socket::IP;
1061
1063
use Errno qw( EINPROGRESS EWOULDBLOCK );
1062
1064
1063
- my @peeraddrinfo = ... # Caller must obtain the getaddinfo result here
1065
+ my @peeraddrinfo = ... # Caller must obtain the getaddrinfo result here
1064
1066
1065
1067
my $socket = IO::Socket::IP->new(
1066
1068
PeerAddrInfo => \@peeraddrinfo,
@@ -1103,10 +1105,14 @@ of the following special forms then special parsing is applied.
1103
1105
The value of the C<...Host > argument will be split to give both the hostname
1104
1106
and port (or service name):
1105
1107
1108
+ =for highlighter
1109
+
1106
1110
hostname.example.org:http # Host name
1107
1111
192.0.2.1:80 # IPv4 address
1108
1112
[2001:db8::1]:80 # IPv6 address
1109
1113
1114
+ =for highlighter language=perl
1115
+
1110
1116
In each case, the port or service name (e.g. C<80 > ) is passed as the
1111
1117
C<LocalService > or C<PeerService > argument.
1112
1118
@@ -1132,16 +1138,16 @@ Returns a 2-element list, containing either the split hostname and port
1132
1138
description if it could be parsed, or the given address and C<undef > if it was
1133
1139
not recognised.
1134
1140
1135
- IO::Socket::IP->split_addr( "hostname:http" )
1141
+ IO::Socket::IP->split_addr( "hostname:http" );
1136
1142
# ( "hostname", "http" )
1137
1143
1138
- IO::Socket::IP->split_addr( "192.0.2.1:80" )
1144
+ IO::Socket::IP->split_addr( "192.0.2.1:80" );
1139
1145
# ( "192.0.2.1", "80" )
1140
1146
1141
- IO::Socket::IP->split_addr( "[2001:db8::1]:80" )
1147
+ IO::Socket::IP->split_addr( "[2001:db8::1]:80" );
1142
1148
# ( "2001:db8::1", "80" )
1143
1149
1144
- IO::Socket::IP->split_addr( "something.else" )
1150
+ IO::Socket::IP->split_addr( "something.else" );
1145
1151
# ( "something.else", undef )
1146
1152
1147
1153
=cut
@@ -1219,7 +1225,7 @@ sub configure
1219
1225
$self -> configure( { %$arg , Family => Socket::AF_INET6() } );
1220
1226
}
1221
1227
1222
- =head1 C<IO::Socket::INET > INCOMPATIBILITES
1228
+ =head1 C<IO::Socket::INET > INCOMPATIBILITIES
1223
1229
1224
1230
=over 4
1225
1231
0 commit comments