我正在尝试收集通过套接字解析的数据。这是我的代码:
import pickle
import SocketServer
class SocketReciever(SocketServer.BaseRequestHandler):
def handle(self):
sint = self.request.makefile('rb')
objectt = pickle.load(sint)
#print(objectt)
ParentClassCall(objectt)
if __name__ == "__main__":
HOST, PORT = "localhost", 60
# Create the server, binding to localhost on port 9999
server = SocketServer.TCPServer((HOST, PORT), SocketReciever)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
server.serve_forever()
data=[]
def ParentClassCall(currentdata):
data.append(currentdata)
我的问题是如何从 SocketReciever 类中调用 ParentClassCall 函数?
我知道这种方法存在安全问题,但它会在没有互联网接入的计算机上运行。