IO-Socket-Multicast6
view release on metacpan or search on metacpan
IO::Socket::Multicast6 - Send and receive IPv4 and IPv6 multicast
messages
SYNOPSIS
use IO::Socket::Multicast6;
# create a new IPv6 UDP socket ready to read datagrams on port 1100
my $s = IO::Socket::Multicast6->new(
Domain=>AF_INET6,
LocalPort=>1100);
# Add an IPv6 multicast group
$s->mcast_add('FF15::0561');
# now receive some multicast data
$s->recv($data,1024);
# Drop a multicast group
$s->mcast_drop('FF15::0561');
# create a new IPv4 UDP socket ready to send datagrams to port 1100
my $s = IO::Socket::Multicast6->new(
Domain=>AF_INET,
PeerDest=>'225.0.0.1',
PeerPort=>1100);
# Set outgoing interface to eth0
$s->mcast_if('eth0');
# Set time to live on outgoing multicast packets
$s->mcast_ttl(10);
# Turn off loopbacking
$s->mcast_loopback(0);
# Multicast a message to group
$s->send( 'hello world!' );
DESCRIPTION
The IO::Socket::Multicast6 module subclasses IO::Socket::INET6 to enable
you to manipulate multicast groups. With this module you will be able to
receive incoming multicast transmissions and generate your own outgoing
multicast packets.
This module uses the same API as IO::Socket::Multicast, but with added
support for IPv6 (IPv4 is still supported). Unlike
IO::Socket::Multicast, this is a pure-perl module.
DEPENDENCIES
This module depends on a number of other modules:
Socket6 version 0.19 or higher.
IO::Socket::INET6 version 2.51 or higher.
IO::Interface version 1.01 or higher.
Socket::Multicast6 0.01 or higher.
Your operating system must have IPv6 and Multicast support.
INTRODUCTION
Multicasting is designed for streaming multimedia applications and for
conferencing systems in which one transmitting machines needs to
distribute data to a large number of clients.
IPv4 addresses in the range 224.0.0.0 and 239.255.255.255 are reserved
for multicasting. IPv6 multicast addresses start with the prefix FF.
These addresses do not correspond to individual machines, but to
multicast groups. Messages sent to these addresses will be delivered to
a potentially large number of machines that have registered their
interest in receiving transmissions on these groups. They work like TV
channels. A program tunes in to a multicast group to receive
transmissions to it, and tunes out when it no longer wishes to receive
the transmissions.
To receive transmissions from a multicast group, you will use
IO::Socket::INET->new() to create a UDP socket and bind it to a local
network port. You will then subscribe one or more multicast groups using
the mcast_add() method. Subsequent calls to the standard recv() method
will now receive messages incoming messages transmitted to the
subscribed groups using the selected port number.
To send transmissions to a multicast group, you can use the standard
send() method to send messages to the multicast group and port of your
choice.
To set the number of hops (routers) that outgoing multicast messages
will cross, call mcast_ttl(). To activate or deactivate the looping back
of multicast messages (in which a copy of the transmitted messages is
received by the local machine), call mcast_loopback().
CONSTRUCTORS
$socket = IO::Socket::Multicast6->new([LocalPort=>$port,...])
The new() method is the constructor for the IO::Socket::Multicast6
class. It takes the same arguments as IO::Socket::INET, except that
the Proto argument, rather than defaulting to "tcp", will default to
"udp", which is more appropriate for multicasting.
To create a UDP socket suitable for sending outgoing multicast
messages, call new() without no arguments (or with "Proto=>'udp'").
To create a UDP socket that can also receive incoming multicast
transmissions on a specific port, call new() with the LocalPort
argument.
If you plan to run the client and server on the same machine, you
may wish to set the IO::Socket ReuseAddr argument to a true value.
This allows multiple multicast sockets to bind to the same address.
METHODS
$success = $socket->mcast_add($multicast_address [,$interface])
The mcast_add() method will add the provided multicast address to
the list of subscribed multicast groups. The address may be provided
either as a dotted-quad decimal, or as a packed IP address (such as
produced by the inet_aton() function). On success, the method will
return a true value.
The optional $interface argument can be used to specify on which
network interface to listen for incoming multicast messages. If the
IO::Interface module is installed, you may use the device name for
the interface (e.g. "tu0"). Otherwise, you must use the IP address
of the desired network interface. Either dotted quad form or packed
IP address is acceptable. If no interface is specified, then the
( run in 1.577 second using v1.01-cache-2.11-cpan-f56aa216473 )