IO-Socket-Multicast6
view release on metacpan or search on metacpan
lib/IO/Socket/Multicast6.pm view on Meta::CPAN
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!' );
=head1 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.
=head2 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.
=head2 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 B<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 B<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().
=head2 CONSTRUCTORS
=over 4
=item $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 B<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
C<Proto=E<gt>'udp'>). To create a UDP socket that can also receive
incoming multicast transmissions on a specific port, call new() with
the B<LocalPort> argument.
If you plan to run the client and server on the same machine, you may
wish to set the IO::Socket B<ReuseAddr> argument to a true value.
This allows multiple multicast sockets to bind to the same address.
=back
=head2 METHODS
=over 4
=item $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
( run in 0.856 second using v1.01-cache-2.11-cpan-f56aa216473 )