Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to multicast messages in a local network using IO::Socket::Multicast module. Here's my attempt:
sender.pl
use strict; use warnings; use IO::Socket::Multicast; my $socket = new IO::Socket::Multicast() or die "cannot create socket: + $!\n"; $socket->mcast_send("this is multicast", '239.1.1.1:9999') or die "err +or: $!\n"; $socket->close();
receiver.pl
use strict; use warnings; use IO::Socket::Multicast; my $socket = new IO::Socket::Multicast( LocalPort => 9999, ) or die "cannot create socket: $!\n"; my $res = $socket->mcast_add('239.1.1.1'); print "subscribe status: $res\n"; my $data; $socket->recv($data, 1024); print "received: $data\n"; $socket->close();
The problem is that the receiver couldn't receive the message, it just kept waiting.
Additionally, I tested the program on 2 machines, interchanging the roles of sender and receiver and probed them using Wireshark Only one machine displayed "membership report group 239.1.1.1" in the info column, while the other had different group IP, even though both machines printed "subscribe status: 1" in the command line. The machine that seemed to be correct is a Windows virtual machine hosted by the other Windows machine.
Why is this happening and how to multicast properly? Any help would be appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to properly send and receive data from multicast?
by Danny (Chaplain) on Aug 31, 2024 at 19:21 UTC | |
by Anonymous Monk on Sep 01, 2024 at 04:19 UTC | |
by cavac (Prior) on Sep 01, 2024 at 13:55 UTC | |
|
Re: How to properly send and receive data from multicast?
by tybalt89 (Monsignor) on Sep 02, 2024 at 05:30 UTC | |
by Anonymous Monk on Sep 04, 2024 at 09:08 UTC |