-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