我使用一种程序通信监测中心,其代码如下:
HOST = # local host
PORT = 50000
SERVER_ADDRESS = HOST, PORT
# set up server socket
s = socket.socket()
s.bind(SERVER_ADDRESS)
s.listen(1)
while True:
conn, addr = s.accept()
connFile = conn.makefile()
name, args, kwargs = cPickle.load(connFile)
name = cPickle.load(connFile)
args = cPickle.load(connFile)
kwargs = cPickle.load(connFile)
res = _exportedMethods[name](*args,**kwargs)
cPickle.dump(res,connFile) ; connFile.flush()
conn.close()
客户网站:
class RemoteFunction(object):
def __init__(self,serverAddress,name):
self.serverAddress = serverAddress
self.name = name
def __call__(self,*args,**kwargs):
s = socket.socket()
s.connect(self.serverAddress)
f = s.makefile()
cPickle.dump((self.name, args, kwargs), f)
cPickle.dump(self.name,f)
cPickle.dump(args,f)
cPickle.dump(kwargs,f)
f.flush()
res = cPickle.load(f)
s.close()
return res
def machine_changed_signal(machine):
HOST =
PORT = 50000
SERVER_ADDRESS = HOST, PORT
advise = RemoteFunction(SERVER_ADDRESS, changes )
advise(machine)
我收到以下错误信息:
Traceback (most recent call last):
File "/home/manch011/disserver/src/disserver/gui/backends/receiver.py", line 71, in run
args = cPickle.load(connFile)
cPickle.UnpicklingError: pickle data was truncated
After my changes the new i get the following error message:
Traceback (most recent call last):
File "/home/manch011/disserver/src/disserver/gui/backends/receiver.py", line 69, in run
name, args, kwargs = cPickle.load(connFile)
EOFError
我不熟悉小盘问,因此不能说是这样,有人可以向我解释。
Thanks in advance Chis