http://www.perlmonks.org?node_id=11116741

oha has asked for the wisdom of the Perl Monks concerning the following question:

dear Monks,

I have a device which sends udp broadcasts as shown in the tcpdump below:

10:23:48.240377 IP 192.168.0.50.49153 > 192.168.0.255.4210: UDP, lengt +h 28
and I wrote the following:
use strict; use warnings; use IO::Socket; my $sock = IO::Socket::INET->new( Type => IO::Socket::SOCK_DGRAM, Proto => 'udp', PeerAddr => '192.168.0.255:4210', Broadcast => 1, ReuseAddr => 1, ); print inet_ntoa($sock->sockaddr()), ":", $sock->sockport(), "\n"; print inet_ntoa($sock->peeraddr()), ":", $sock->peerport(), "\n"; my $data; $sock->recv($data, 100) or die "$!"; print "«$data»\n";
which shows:
192.168.0.49:37550 192.168.0.255:4210
and then blocks forever, even tho tcpdump shows activity.

What am i doing wrong?