Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Point me in the right direction - Monitor a Mulicast IP address or stream

by VinsWorldcom (Prior)
on Aug 20, 2013 at 14:45 UTC ( [id://1050192]=note: print w/replies, xml ) Need Help??


in reply to Point me in the right direction - Monitor a Mulicast IP address or stream

Perl can listen on multicast streams easily with IO::Socket::Multicast. There is even an IPv6 version at IO::Socket::Multicast6.

Here is a simple multicast listener example (IPv4-only):

#!/usr/bin/perl use strict; use warnings; use IO::Socket::Multicast; my $sock = IO::Socket::Multicast->new( LocalPort => 7070, ReuseAddr => 1 ) or die "Cannot create client\n";; $sock->mcast_add("239.192.1.1") || die "Cannot set group: $!\n"; my $data; while (1) { $sock->recv($data,1024); my $peer_addr = $sock->peerhost(); my $peer_port = $sock->peerport(); print "($peer_addr:$peer_port): $data\n" }

You can use a select() timer instead of the while loop and if you reach a timeout - send the email.

  • Comment on Re: Point me in the right direction - Monitor a Mulicast IP address or stream
  • Download Code

Replies are listed 'Best First'.
Re^2: Point me in the right direction - Monitor a Mulicast IP address or stream
by PerlSufi (Friar) on Aug 20, 2013 at 14:49 UTC
Re^2: Point me in the right direction - Monitor a Mulicast IP address or stream
by jasonjackal (Initiate) on Aug 20, 2013 at 19:00 UTC
    Thanks everyone for the quick and detailed replies. I will continue to discover and understand these findings.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1050192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-26 05:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found