On Wed, Aug 12, 2009 at 12:04 AM, gregarican<greg.kuj...@gmail.com> wrote: > On Aug 11, 2:14 pm, "squishywaf...@gmail.com" > <squishywaf...@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 -- http://mail.python.org/mailman/listinfo/python-list