python - AttributeError: EchoFactory instance has no attribute 'doStart' -


i'm learning twisted , here first server example:

from twisted.internet import protocol, reactor  class echo(protocol.protocol):     def datareceived(self, data):         self.transport.write(data)  class echofactory(protocol.protocol):     def buildprotocal(self, addr):        return echo()  reactor.listentcp(8000, echofactory()) reactor.run() 

and got error, tried reinstall library still didn't work:

traceback (most recent call last): file "/home/trieu/desktop/server.py", line 11, in <module> reactor.listentcp(8000, echofactory()) file "/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py",  line 495, in listentcp p.startlistening() file "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 998,  in startlistening self.factory.dostart() attributeerror: echofactory instance has no attribute 'dostart' 

echofactory should extend protocol.factory, not protocol.protocol. also, have typo in overridden method name, buildprotocol.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -