Socket::Multicast - Constructors and constants for multicast socket operations.


Socket-Multicast documentation Contained in the Socket-Multicast distribution.

Index


Code Index:

NAME

Top

Socket::Multicast - Constructors and constants for multicast socket operations.

SYNOPSIS

Top

  use Socket::Multicast qw(:all);

  my $ip = getprotobyname( 'ip' );

  my $ip_mreq = pack_ip_mreq( inat_aton( $mcast_addr ), inet_aton( $if_addr ) );

  setsockopt( $sock, $ip, IP_ADD_MEMBERSHIP, $ip_mreq )
    or die( "setsockopt IP_ADD_MEMBERSHIP failed: $!" );

  setsockopt( $sock, $ip, IP_DROP_MEMBERSHIP, $ip_mreq )
    or die( "setsockopt IP_DROP_MEMBERSHIP failed: $!" );

  setsockopt( $sock, $ip, IP_MULTICAST_LOOP, pack( 'C', $loop ) )
    or die( "setsockopt IP_MULTICAST_LOOP failed: $!" );

  setsockopt( $sock, $ip, IP_MULTICAST_TTL, pack( 'C', $ttl ) )
    or die( "setsockopt IP_MULTICAST_TTL failed: $!" );

DESCRIPTION

Top

This module is used to gain access to constants and utility functions used when manipulating multicast socket attributes. This module allows you to do the same things as IO::Socket::Multicast, but this is the long way.

FUNCTIONS

Top

IP_MREQ = pack_ip_mreq MCAST_ADDR, IF_ADDR

CONSTANTS

Top

IP_MULTICAST_IF

IP_MULTICAST_TTL

IP_MULTICAST_LOOP

IP_ADD_MEMBERSHIP

IP_DROP_MEMBERSHIP

SEE ALSO

Top

IO::Socket::Multicast (The fast way)

AUTHOR

Top

Jonathan Steinert, <hachi@cpan.org>

COPYRIGHT AND LICENSE

Top


Socket-Multicast documentation Contained in the Socket-Multicast distribution.

package Socket::Multicast;
use strict;
use warnings;

use Carp;

our $VERSION = '0.01';
our $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;

require XSLoader;
XSLoader::load('Socket::Multicast', $XS_VERSION);

require Exporter;

our @ISA = qw(Exporter);

our %EXPORT_TAGS = ( 'all' => [ qw(
	IP_MULTICAST_IF
	IP_MULTICAST_TTL
	IP_MULTICAST_LOOP
	IP_ADD_MEMBERSHIP
	IP_DROP_MEMBERSHIP
	pack_ip_mreq
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

our @EXPORT = qw();

sub AUTOLOAD {
    # This AUTOLOAD is used to 'autoload' constants from the constant()
    # XS function.  If a constant is not found then control is passed
    # to the AUTOLOAD in AutoLoader.

    my $constname;
    our $AUTOLOAD;
    ($constname = $AUTOLOAD) =~ s/.*:://;
    croak "&Socket::Multicast::constant not defined" if $constname eq 'constant';
    my ($error, $val) = constant($constname);
    if ($error) {
	if ($error =~  /is not a valid/) {
	    $AutoLoader::AUTOLOAD = $AUTOLOAD;
	    goto &AutoLoader::AUTOLOAD;
	} else {
	    croak $error;
	}
    }
    {
	no strict 'refs';
	# Fixed between 5.005_53 and 5.005_61
#	if ($] >= 5.00561) {
#	    *$AUTOLOAD = sub () { $val };
#	}
#	else {
	    *$AUTOLOAD = sub { $val };
#	}
    }
    goto &$AUTOLOAD;
}


# Preloaded methods go here.

1;
__END__