in reply to Re: Re: udp broadcast: doesn't work in Linux
in thread udp broadcast: doesn't work in Linux

I should have been more clear... The error is occurring when the peer name is undefined in IO::Socket. It won't give you an error when it can't determine the peer address, it just returns undef. Then the call to send in IO::Socket croaks when peer name is undefined:

    croak 'send: Cannot determine peer address'
         unless($peer);
So getpeername($sock) returning undef is what I expected would happen, I just didn't explain that well enough. It should return the address of the peer at the remote end of the socket.

Try this and vary the $bcaddr in your script:

my ($port, $addr) = unpack_sockaddr_in(getpeername($sock));
my $host = gethostbyaddr($addr, AF_INET);
print "Host:\t$host\n";
print "Port:\t$port\n";


  • Comment on Re: Re: Re: udp broadcast: doesn't work in Linux