Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   UDP Broadcast Packet (offtopic) (http://www.velocityreviews.com/forums/t808574-udp-broadcast-packet-offtopic.html)

Martin Farnik 07-04-2003 07:34 AM

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





ts 07-04-2003 10:28 AM

Re: UDP Broadcast Packet (offtopic)
 
>>>>> "M" == Martin Farnik <martin.farnik@email.cz> writes:

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










Josef 'Jupp' Schugt 07-04-2003 01:43 PM

Re: UDP Broadcast Packet (offtopic)
 
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


ts 07-04-2003 01:59 PM

Re: UDP Broadcast Packet (offtopic)
 
>>>>> "J" == Josef 'Jupp' Schugt <jupp@gmx.de> writes:

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



All times are GMT. The time now is 01:53 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.