[Twisted-Python] UDP question

Alec Matusis matusis at matusis.com
Sat Jul 8 18:54:43 EDT 2006

>You can have as many processes listening on a single MULTICAST UDP port as
you like. 

Well, I am trying to run this example multicast UDP server:
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
from twisted.application.internet import MulticastServer
class MulticastServerUDP(DatagramProtocol):
    def startProtocol(self):
        print 'Started Listening'
        # Join a specific multicast group
    def datagramReceived(self, datagram, address):

reactor.listenMulticast(8005, MulticastServerUDP())
when I try running more that one instance of this on the same machine I get
twisted.internet.error.CannotListenError: Couldn't listen on any:8005: (98,
'Address already in use').
So my quiestion is how can I have multiple processes listening for multicast
on the same machine?


From: twisted-python-bounces at twistedmatrix.com
[mailto:twisted-python-bounces at twistedmatrix.com] On Behalf Of jarrod
Sent: Saturday, July 08, 2006 2:57 PM
To: Twisted general discussion
Subject: Re: [Twisted-Python] UDP question

On 7/8/06, Alec Matusis <matusis at matusis.com> wrote: 

	I have a question about using UDP in twisted. I hope people will
forgive my
	naiveté, since my background is in physics, not in CS, so I am
	and may be missing something obvious.
	I would like a server to send UDP broadcasts to multiple clients,
where all 
	clients receive the same broadcast.
	>From what I understood from
	Multicast UDP section, one can have a client broadcast the same UDP
	to multiple servers, each server listening on the same port for this
	This is unacceptable for me, since all of this must happen on the
	machine, so I cannot bind multiple servers to the same port on one
box. So I
	am trying to implement a reverse scenario, where the server will do
	multicast to clients, but all clients and the server may (or may
not) be 
	running on the same box.

actually you can, you need to read up on how MULTICAST works.
It isn't the same thing as uni-cast UDP.
You can have as many processes listening on a single MULTICAST UDP port as
you like. 

ZeroConf / Apple Bonjour ( formerly Rendezous ) usings multicast udp to do
just that.

	How can I do this in twisted? Could you give me and example? Thanks.

If you don't know what you want, you probably need a nap.

More information about the Twisted-Python mailing list