[Twisted-Python] UDP and factories
John Janecek
jjanecek at telusplanet.net
Fri Aug 8 17:18:05 MDT 2003
I am attempting to use DatagramProtocol with a factory
are u supposed to use DatagramProtocol with a factory ??
am i out to lunch ?
ie
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
reactor.listenUDP(6000,echo_factory)
reactor.run()
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 ?
reactor.listenUDP(6000,echo_factory)
File "E:\Python22\Lib\site-packages\twisted\internet\default.py", line
181, in
listenUDP
p = udp.Port(port, protocol, interface, maxPacketSize, self)
File "E:\Python22\Lib\site-packages\twisted\internet\udp.py", line 65,
in __in
it__
assert isinstance(proto, protocol.DatagramProtocol)
AssertionError
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