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:
and I wrote the following:10:23:48.240377 IP 192.168.0.50.49153 > 192.168.0.255.4210: UDP, lengt +h 28
which shows: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";
and then blocks forever, even tho tcpdump shows activity.192.168.0.49:37550 192.168.0.255:4210
What am i doing wrong?
Back to
Seekers of Perl Wisdom