[Twisted-Python] How can I call internet.MulticastServer() to enable listenMultiple?

Brian Warner warner at lothar.com
Sun Apr 3 19:54:56 EDT 2005


>> Why are you passing a factory in? UDP and Multicast don't use factories.
>
> Ok what I am trying to do is make a ZeroConfService

It is worth pointing out that IP Multicast works in terms of _groups_. When
you are listening on a socket, you must specify both UDP port number and the
group id. (IPv4 groups are specified with an IP address in the "class D"
range, 224.foo.foo.foo). If you just listen on port 5353, you're listening
for packets directed at one of your node's unicast ip addresses. If you bind
it to a specified group (224.0.0.251 is probably the one you want), then you
get packets sent to that multicast group, and multiple programs on a single
host can listen on the same multicast group.

Itamar's mdns.py code in the sandbox[1] uses the following routine (in a
DatagramProtocol subclass) to set up the receiver:

    def startListening(self):
        reactor.listenMulticast(5353, self, maxPacketSize=1024,
                                listenMultiple=True)
        self.transport.joinGroup(MDNS_ADDRESS)
        self.transport.setTTL(255)
        self.transport.setLoopbackMode(False)

You'll probably need to do something similar.

cheers,
 -Brian


[1]: svn://svn.twistedmatrix.com/svn/Twisted/sandbox/itamar/mdns




More information about the Twisted-Python mailing list