找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 7891|回复: 1

[求助] twisted中遇到的问题

1

主题

1

帖子

0

积分

贫民

积分
0
小虫子 发表于 2013-3-24 11:14:36 | 显示全部楼层 |阅读模式
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__'
小弟在写代码时遇到的问题,求大神解答。。。。
回复

使用道具 举报

0

主题

6

帖子

28

积分

贫民

积分
28
海风aa 发表于 2013-3-24 21:41:05 | 显示全部楼层
帮你顶
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表