[Twisted-Python] UDP and factories

John Janecek jjanecek at telusplanet.net
Fri Aug 8 19:18:05 EDT 2003

I am attempting to use DatagramProtocol with a factory
are u supposed to use DatagramProtocol with a factory ??
am i out to lunch ?


from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
from twisted.internet.protocol import Factory

class Echo(DatagramProtocol):
     def datagramReceived(self, data, (host, port)):
         print "received %r from %s:%d" % (data, host, port)
         self.transport.write(data, (host, 7000))

echo_factory = Factory()
echo_factory.protocol = Echo


I am using twisted v 1.05 and windows XP

everytime i attempt to run the above code i get

Traceback (most recent call last):
   File "pyRtp.py", line 97, in ?
   File "E:\Python22\Lib\site-packages\twisted\internet\default.py", line 
181, in
     p = udp.Port(port, protocol, interface, maxPacketSize, self)
   File "E:\Python22\Lib\site-packages\twisted\internet\udp.py", line 65, 
in __in
     assert isinstance(proto, protocol.DatagramProtocol)

what am i doing wrong ?
If i am not supposed to use a factory with UDP what is a better solution ?

Thanx :)

More information about the Twisted-Python mailing list