IO-Socket-Multicast

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    IO::Socket::Multicast - Send and receive multicast messages

SYNOPSIS
      use IO::Socket::Multicast;

      # create a new UDP socket ready to read datagrams on port 1100
      my $s = IO::Socket::Multicast->new(LocalPort=>1100);

      # Add a multicast group
      $s->mcast_add('225.0.1.1');

      # Add a multicast group to eth0 device
      $s->mcast_add('225.0.0.2','eth0');

      # now receive some multicast data
      $s->recv($data,1024);

      # Drop a multicast group
      $s->mcast_drop('225.0.0.1');

      # 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 225.0.0.1
      $s->mcast_send('hello world!','225.0.0.1:1200');
      $s->mcast_set('225.0.0.2:1200');
      $s->mcast_send('hello again!');

DESCRIPTION
    The IO::Socket::Multicast module subclasses IO::Socket::INET to enable
    you to manipulate multicast groups. With this module (and an operating
    system that supports multicasting), you will be able to receive incoming
    multicast transmissions and generate your own outgoing multicast
    packets.

    This module requires IO::Interface version 0.94 or higher.

  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.

    IP addresses in the range 224.0.0.0 and 239.255.255.255 are reserved for
    multicasting. 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. The mcast_set() and mcast_send() methods are provided as
    convenience functions. Mcast_set() will set a default multicast
    destination for messages which you then send with mcast_send().

    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::Multicast->new([LocalPort=>$port,...])
        The new() method is the constructor for the IO::Socket::Multicast
        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 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



( run in 1.690 second using v1.01-cache-2.11-cpan-39bf76dae61 )