Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: udp broadcast: doesn't work in Linux

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


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

Well, this is tough, because it seems your script isn't at fault.

It looks like the call to getpeername($sock) is failing for this socket in IO::Socket.

Try calling that directly in your script and see if you get the error at that point.

Try connecting to another host/port. It's hard to diagnose without knowing more about your network config and the circumstances of this test.

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

Replies are listed 'Best First'.
Re: Re: udp broadcast: doesn't work in Linux
by fjonckers (Novice) on Oct 11, 2001 at 23:34 UTC
    thanks cjensen!
    I added the following just below the socket creation and above the send method:
    print "\ngetpeername: " . getpeername($sock) . "\n";
    output is:
    getpeername: send: Cannot determine peer address at udp.pl line 26
    so, no error when calling getpeername...
    checking the linux kernel road.. woulb be very strange if you cannot send something to a LAN broadcast address
    tried other port values... nothing (port is random)
    F.
      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";


Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found