|
from twisted.internet import reactor
from twisted.internet.protocol import Protocol, Factory
class SimpleLogger(Protocol):
def connectionMade(self):
print 'get connection from: ', self.transport.client
def connectionLost(self, reason):
print self.transport.client, 'disconnected'
def dataReceived(self, data):
print data
factory = Factory()
factory.protocol = SimpleLogger
reactor.listenTCP(4567, Factory)
reactor.run()
Traceback (most recent call last):
File "D:\Python25\prtwisted1.py", line 14, in <module>
reactor.listenTCP(4567, Factory)
File "D:\Python25\lib\site-packages\twisted\internet\posixbase.py", line 419, in listenTCP
p.startListening()
File "D:\Python25\lib\site-packages\twisted\internet\tcp.py", line 863, in startListening
log.msg("%s starting on %s" % (self.factory.__class__, self._realPortNumber))
AttributeError: class Factory has no attribute '__class__'
小弟在写代码时遇到的问题,求大神解答。。。。 |
|