我正在尝试通过套接字发送Keras顺序模型,但没有收到比发送的要多的位。
我尝试使用sendall
代替send
,并尝试一次接收所有软件包,并将其拆分。
client.py
msg = pickle.dumps(self.output)
print('Size:', sys.getsizeof(msg))
self.client.send(msg)
server.py
data = []
received = 0
while True:
packet = conn.recv(1024)
received += sys.getsizeof(packet)
print(packet)
print(sys.getsizeof(packet), received)
if packet: data.append(packet)
if not packet or packet == b'' or sys.getsizeof(packet) < 1024:
break
print(sys.getsizeof(data))
y = pickle.loads(b"".join(data))
我期望received
的大小最终应与sys.getsizeof(msg)
相同,只是它的大小要小数千位。