Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Re: udp broadcast: doesn't work in Linux

by cjensen (Sexton)
on Oct 12, 2001 at 00:39 UTC ( [id://118337]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://118337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-04-18 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found