[Twisted-Python] UDP Factories

Justin Johnson justinjohnson at fastmail.fm
Fri Sep 19 07:42:08 EDT 2003

I have a UDP protocol that subclasses DatagramProtocol.  It is working
fine, but I decided I wanted a protocol factory so I can keep track of
the list of clients.  I added the following class, which doesn't nothing

class MyProtoFactory(Factory):
    protocol = MyProto
And then changed my reactor.listenUDP line to...

    reactor.listenUDP(config.SERVER_PORT, MyProtoFactory())

[justinj at chewie travis]$ ./udpserver.py
Traceback (most recent call last):
  File "./udpserver.py", line 166, in ?
    reactor.listenUDP(config.SERVER_PORT, MyProtoFactory())
  line 180, in listenUDP
    p = udp.Port(port, protocol, interface, maxPacketSize, self)
  File "/usr/local/lib/python2.3/site-packages/twisted/internet/udp.py",
  line 66, in __init__
    assert isinstance(proto, protocol.DatagramProtocol)

Any idea what I'm doing wrong?  The examples showed a UDP factory, but I
don't quite see how this would work.


More information about the Twisted-Python mailing list