drbrain / ruby-growl

Pure-Ruby Growl Notifier
49 stars 10 forks source link

broadcast address #9

Closed osbornebrook closed 10 years ago

osbornebrook commented 12 years ago

there maybe a better way of doing this, but I have added the socket option Socket::SO_BROADCAST to allow for broadcast growls

drbrain commented 12 years ago

Not every subnet is going to end on 255. Why not detect 255.255.255.255 instead?

osbornebrook commented 12 years ago

In a mutli-homed host I wanted to have the option of broadcasting to a single network (i.e. 192.168.x.255) and not to the whole world on the public interface. An alternative might be that we use another option ( "-b" ) to indicate that we want to broadcast and if the host is not specified (so I don't explicitly set my network) then it uses 255.255.255.255. What do you think ? (I would be happy to update the code!)

drbrain commented 12 years ago

I think your idea is good. Just to make sure, --broadcast would force the growl_type argument of #initialize to 'UDP' and the --host would be optional.

So with a network of 192.0.2.0/24:

growl --broadcast uses 255.255.255.255 and UDP

growl --broadcast --host 192.0.2.255 uses 19.0.2.255 and UDP

growl --host 192.0.2.255 uses 192.0.2.255 and auto-detects GNTP or UDP (even though this is not a valid host to connect to).

brandon-dacrib commented 11 years ago

Was this ever implemented in stable?

drbrain commented 10 years ago

UDP broadcast does not work with modern growl. I've implemented UDP broadcast sending but it does nothing with growl 2.x. I can't get growl 1.x to work at all on OS X 10.9. I will ship the UDP broadcast code for API use only, maybe someone will find this useful.