UDP Broadcast Packet (offtopic)

Hi,
I’ve problem to send UDP Packet with broadcast address from ruby (in Linux).

When i run this code:

require ‘socket’

UDPSocket.open.send(ArtPoll, 0, “2.255.255.255”,0x1936)

I get
…/ethtest.rb:28:in `send’: Permission denied - “sendto(2)” (Errno::EACCES)
from ./ethtest.rb:28

Thanks for answars

Martin Farnik

email:cmarty@mail.cz

I get
../ethtest.rb:28:in `send': Permission denied - "sendto(2)" (Errno::EACCES)
        from ./ethtest.rb:28

You must call #setsockopt to specify the option Socket::SO_BROADCAST,
before calling #send

Guy Decoux

Saluton!

  • Martin Farnik; 2003-07-04, 09:49 UTC:

require ‘socket’

UDPSocket.open.send(ArtPoll, 0, “2.255.255.255”,0x1936)

I get
…/ethtest.rb:28:in `send’: Permission denied - “sendto(2)” (Errno::EACCES)
from ./ethtest.rb:28

I get ‘uninitialized constant ArtPoll (NameError)’

Gis,

Josef ‘Jupp’ Schugt

···


Someone even submitted a fingerprint for Debian Linux running on the
Microsoft Xbox. You have to love that irony :).
– Fyodor on nmap-hackers@insecure.org

I get 'uninitialized constant ArtPoll (NameError)'

Well, if you want an example

svg% cat b.rb
#!/usr/bin/ruby
require 'socket'
s = UDPSocket.open
s.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, 1)
p s.send("moulon.inra.fr", 0, "138.102.114.255",0x1936)
svg%

svg% b.rb
14
svg%

comment the line with #setsockopt and you'll have an error

Guy Decoux