[Twisted-Python] Unable to get the UDP multicasting examples to work

Alan Rushforth Alan.Rushforth at student.shu.ac.uk
Thu Nov 20 03:48:10 MST 2003


Hi,

This may well be a very trivial question but i have been trying to get the UDP
multicasting example in the "how to" section of the twisted documentation to
work and have had no success. I can do TCP message and normal UDP but cant
multicast it.

It does not report any errors but nothing every seems to be received by the
echo server.
Don't I need to explicitly join the multicast group at any point?

The code i have been using is as follows:
The multicast client:

from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
class Client(DatagramProtocol): 
	def datagramReceived(self, data, host):
	 	print 'Response Recieved:', data.strip()
		print 'From Host:', host
reactor.listenUDP(0, Client()).write('broadcast\n', ('224.0.0.1', 9999))
reactor.run() 

The original Echo server:

from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
class Echo(DatagramProtocol):
	def datagramReceived(self, data, (host, port)):
		print "received %r from %s:%d" % (data, host, port)
		self.transport.write(data, (host, port))
reactor.listenUDP(9999, Echo())
reactor.run() 

Thanks for any help,
Alan.





More information about the Twisted-Python mailing list