Hi James,

On Sun, 5 Apr 2020 14:58:26 +0100
James Kerwin <jkerwin2...@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

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to