def _send_message(connection, message):
# Packing the length of the entire msg using struct.pack.
# This enables later reading of the content.
def _pack(data):
return struct.pack(_INT_FMT, len(data))
data = jsonpickle.dumps(message)
msg_metadata = _pack(data)
connection.send(msg_metadata)
connection.sendall(data)
评论列表
文章目录