UDP Broadcast Packet (offtopic)

M

Martin Farnik

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:[email protected]
 
T

ts

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

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


Guy Decoux
 
J

Josef 'Jupp' Schugt

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
 
T

ts

J> 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top