-4
我有一个使用Twisted在Python中运行的基本服务器程序。我试图拒绝用户,并试图使用self.sock.close()
。当这条线被称为我得到一个异常:实例没有属性'sock'
AttributeError: IphoneChat instance has no attribute 'sock'.
这很奇怪,因为之前这行代码被执行,而不是引起异常:
from twisted.internet.protocol import Protocol, Factory
from twisted.internet import reactor
class IphoneChat(protocol):
def connectionMade(self):
self.sock.close()
return
也就是说它现在我改变了它的时候我试图拒绝传入的连接。
我们需要实际看到一些代码,然后才能发表任何评论。 –
好吧,我会编辑它 – Charlie