Networked Broadcast Messaging

Kushal Kumaran kushal.kumaran+python at gmail.com
Tue Aug 11 15:00:37 EDT 2009


On Wed, Aug 12, 2009 at 12:04 AM, gregarican<greg.kujawa at gmail.com> wrote:
> On Aug 11, 2:14 pm, "squishywaf... at gmail.com"
> <squishywaf... at gmail.com> wrote:
>> I'm not exactly sure what the term for this would be, but I was
>> wondering if there were any Python packages that supported some kind
>> of ad-hoc message broadcasting. What I'd like to do is something like
>> this:
>>
>> * On a number of workhorse machines, a process listens for network
>> messages from our broadcast service. It subscribes to a certain sub-
>> set of them and will only respond to the messaging events that it is
>> subscribed to.
>> * Any machine can broadcast a message out to the network of machines
>> without specifying an IP address.
>> * Machines can come and go. Since messages are not directly sent to a
>> specific IP address from our Python script, the messages are simply
>> broadcasted to those who are there to listen. If nobody is subscribed
>> to the message type being sent, nothing happens.
>>
>> I know XML-RPC and other friends are an option, but I'm looking for
>> something that doesn't require managing a set of IP addresses or
>> hostnames. I'm not sure what to Google for such a package/module, any
>> direction would be greatly appreciated.
>
> Offhand I'd suggest binding a specific UDP port on the listening
> workstations. Then the broadcasting workstation(s) could just pull a
> standard list of IP's based on its own subnet. Then there'd be no hard-
> coded machine names or IP addresses to manage. Just send the message
> to all hosts on the same subnet as the broadcaster(s). Plus the UDP
> connection would be stateless and not care if the receivers actually
> got the message or not...

You could use the socket module to broadcast.  Using INADDR_BROADCAST
as the destination should do it.  I fail to recollect whether that
will need root privileges...

-- 
kushal



More information about the Python-list mailing list