package Socket;
our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
-$VERSION = "1.75";
+$VERSION = "1.85";
=head1 NAME
-Socket, sockaddr_in, sockaddr_un, inet_aton, inet_ntoa - load the C socket.h defines and structure manipulators
+Socket, sockaddr_in, sockaddr_un, inet_aton, inet_ntoa, inet_pton, inet_ntop - load the C socket.h defines and structure manipulators
=head1 SYNOPSIS
$proto = getprotobyname('tcp');
socket(Socket_Handle, PF_UNIX, SOCK_STREAM, $proto);
- unlink('/tmp/usock');
- $sun = sockaddr_un('/tmp/usock');
+ unlink('/var/run/usock');
+ $sun = sockaddr_un('/var/run/usock');
connect(Socket_Handle,$sun);
=head1 DESCRIPTION
Returns the 4-byte 'invalid' ip address. Normally equivalent
to inet_aton('255.255.255.255').
+=item sockaddr_family SOCKADDR
+
+Takes a sockaddr structure (as returned by pack_sockaddr_in(),
+pack_sockaddr_un() or the perl builtin functions getsockname() and
+getpeername()) and returns the address family tag. It will match the
+constant AF_INET for a sockaddr_in and AF_UNIX for a sockaddr_un. It
+can be used to figure out what unpacker to use for a sockaddr of
+unknown type.
+
=item sockaddr_in PORT, ADDRESS
=item sockaddr_in SOCKADDR_IN
and returns the pathname. Will croak if the structure does not
have AF_UNIX in the right place.
+=item inet_pton ADDRESS_FAMILY, HOSTNAME
+
+Takes an address family, either AF_INET or AF_INET6, and a string giving
+the name of a host, and translates that to an opaque string
+(if programming in C, struct in_addr or struct in6_addr depending on the
+address family passed in). The host string may be a string hostname, such
+as 'www.perl.org', or an IP address. If using an IP address, the type of
+IP address must be consistant with the address family passed into the function.
+
+=item inet_ntop ADDRESS_FAMILY, IP_ADDRESS
+
+Takes an address family, either AF_INET or AF_INET6, and a string
+(an opaque string as returned by inet_aton() or inet_pton()) and
+translates it to an IPv4 or IPv6 address string.
+
=back
=cut
use XSLoader ();
@ISA = qw(Exporter);
@EXPORT = qw(
- inet_aton inet_ntoa pack_sockaddr_in unpack_sockaddr_in
+ inet_aton inet_ntoa
+ inet_pton inet_ntop
+ sockaddr_family
+ pack_sockaddr_in unpack_sockaddr_in
pack_sockaddr_un unpack_sockaddr_un
sockaddr_in sockaddr_un
INADDR_ANY INADDR_BROADCAST INADDR_LOOPBACK INADDR_NONE
AF_WAN
AF_X25
IOV_MAX
+ IP_OPTIONS
+ IP_HDRINCL
+ IP_TOS
+ IP_TTL
+ IP_RECVOPTS
+ IP_RECVRETOPTS
+ IP_RETOPTS
MSG_BCAST
MSG_BTAG
MSG_CTLFLAGS
@EXPORT_OK = qw(CR LF CRLF $CR $LF $CRLF
+ IPPROTO_IP
+ IPPROTO_IPV6
+ IPPROTO_RAW
+ IPPROTO_ICMP
IPPROTO_TCP
+ IPPROTO_UDP
+
TCP_KEEPALIVE
TCP_MAXRT
TCP_MAXSEG