develooper Front page | perl.beginners | Postings from April 2020

Re: IO::Socket::Multicast::mcast_send

Thread Previous | Thread Next
From:
James Kerwin
Date:
April 5, 2020 18:05
Subject:
Re: IO::Socket::Multicast::mcast_send
Message ID:
CAKkNZ9A8PxOxtqN26Cwtjaes-EGADACSgH=kJo9+qjc_OkB_jw@mail.gmail.com
Ahhhh I managed to find the problem thanks to somebody else finding it late
last year.

With the particular verison of Perl on the Pi (I think I said 5.28) there
is a bug for the IO::Socket::Multicast module:

https://rt.cpan.org/Public/Bug/Display.html?id=130581

To fix it I went in to where the Multicast.pm file lives and implemented
the suggested changes.

I know the correct thing to do was probably to make a local copy of the
file and point to it, or switch to a younger version of Perl, but it's a
personal project on a Pi that I'm likely to wipe in a few months.

Script(s) work now!

Thanks for the help.

James


On Sun, Apr 5, 2020 at 4:03 PM Shlomi Fish <shlomif@shlomifish.org> wrote:

> Hi James,
>
> On Sun, 5 Apr 2020 14:58:26 +0100
> James Kerwin <jkerwin2101@gmail.com> wrote:
>
> > Hi All,
> >
> > I'm trying to connect to a smart bulb on my home WIFI using mcast_send
> > in IO::Socket::Multicast.
> >
> > It works on my main Linux Mint laptop. The same script does not work on
> my
> > Raspberry PI.
> >
> > Despite the script running as expected on one laptop I've checked that
> this
> > is all set up correctly:
> >
> > sub new {
> >     #my $class = shift;
> >     my $data  = {
> >         address => '239.255.255.250',
> >         port    => 1982,
> >         timeout => 3,
> >         devices => [],
> >     };
> >     return bless( $data );
> > }
> >
>
> It is a good idea to use bless with an explicit package name or just use
> https://metacpan.org/pod/Moo or Moose or similar.
>
> > my $socket = IO::Socket::Multicast->new(
> >         PeerAddr  => $self->{address},
> >         PeerPort  => $self->{port},
> >         Proto     => "udp",
> >         ReuseAddr => 1,
> >     ) or croak $!;
> >
> > But it's this part that fails on the PI:
> >
>
> A few things to check:
>
> 1. Which OS/distro/version and perl version  on both machines?
>
> 2. Does it happen with the latest stable perl installed from source?
>
> 3. Did you try using https://en.wikipedia.org/wiki/GDB and/or perl -d:
> https://perl-begin.org/topics/debugging/ ?
>
> 4. Is there anything in the rpi's firewall config?
>
> For more advice, see
> https://github.com/shlomif/writing-the-perfect-question .
>
> > $socket->mcast_send( $query, "$self->{address}:$self->{port}" ) or croak
> $!;
> >
> > I've checked that $socket, $query and $self->{address}:$self->{port}
> > contain the info I expect and they do.
> >
> > On my Linux laptop I can use tcpdump and see the communication between
> > laptop and bulb. Doing this on the Pi shows no communication. I've
> replaced
> > the "croak" with "die "zzzzzzzzzzzz" so I can be certain it's failing at
> > that point. I get the output "zzzzzzzzzzzz" (makes it easier to spot).
> >
> > I've just used a command recently that allows me to access the specific
> ip
> > and port of the lamp and it indicates the connection is successful. I'm
> out
> > of ideas and if anyone can advise I'd appreciate it.
> >
> > Slightly (very) out of my depth when it comes to ports and IPs etc.
> >
> > Thanks,
> > James
>
>
>
> --
>
> Shlomi Fish       https://www.shlomifish.org/
> https://github.com/shlomif/validate-your-html - Validate Your HTML
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About