Have you tried binding to the network broadcast address rather than the 
global broadcast address ?

e.g. 192.168.1.255

Also, there are anycast address spaces.  What address is the UDP packet 
broadcast on ? 255.255.255.255

Joel VanderWerf wrote:

>
> I'm trying to use ruby to immitate some C code that broadcasts UDP 
> packets, but I can only seem to receive packets that are sent to a 
> specific interface address, not to a broadcast address. Here are the 
> sender and receiver:
>
> ==== sender.rb ====
> require 'socket'
>
> port = 1234
>
> #host = "localhost"
> host = "192.168.1.3"
>
> #host = "<broadcast>"
> #host = "255.255.255.255"
>
> socket = UDPSocket.open
> socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
>
> loop do
>   socket.send("sample data", 0, host, port)
>   sleep 0.1
> end
> ====
>
> ==== receiver.rb ====
> require 'socket'
>
> port = 1234
>
> #host = "localhost"
> host = "192.168.1.3"
>
> #host = "<any>"
> #host = "255.255.255.255"
> #host = ""
> #host = nil
>
> socket = UDPSocket.open
> socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
>
> socket.bind(host, port)
> p socket.recvfrom(20)
> ====
>
> As the two programs are written, the receiver prints out "sample 
> data". That's also the case when both programs use
>
>   host = "localhost"
>
> But for any combination of the broadcast hosts (e.g., "<broadcast>" 
> and "<any>"), the receiver doesn't get the packet.
>
> Any help is appreciated.