Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by VinsWorldcom (Priest)
on Aug 20, 2013 at 14:45 UTC ( #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
Re^2: Point me in the right direction - Monitor a Mulicast IP address or stream
by PerlSufi (Pilgrim) 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
Node Status?
node history
Node Type: note [id://1050192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2014-07-26 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (179 votes), past polls