UDP Broadcast Packet (offtopic)

Discussion in 'Ruby' started by Martin Farnik, Jul 4, 2003.

  1. 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:
    Martin Farnik, Jul 4, 2003
    #1
    1. Advertising

  2. Martin Farnik

    ts Guest

    >>>>> "M" == Martin Farnik <> 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
    ts, Jul 4, 2003
    #2
    1. Advertising

  3. 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
    Josef 'Jupp' Schugt, Jul 4, 2003
    #3
  4. Martin Farnik

    ts Guest

    >>>>> "J" == Josef 'Jupp' Schugt <> 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
    ts, Jul 4, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lincoln Yeoh
    Replies:
    1
    Views:
    532
    Jorgen Grahn
    Sep 3, 2005
  2. Irmen de Jong
    Replies:
    9
    Views:
    769
    Irmen de Jong
    Apr 11, 2007
  3. Li Han
    Replies:
    2
    Views:
    488
    bobicanprogram
    Feb 9, 2009
  4. Lincoln Yeoh
    Replies:
    0
    Views:
    88
    Lincoln Yeoh
    Sep 3, 2005
  5. Lincoln Yeoh
    Replies:
    2
    Views:
    90
    Lincoln Yeoh
    Sep 6, 2005
Loading...

Share This Page