我会直接前进:
这个命令:
chat_manager.send(self.player, protocol.KA().encode("h"))
提出了这个观点:
chat_manager.send(间距出错了。忽略):
def send(player, data):
try:
player.send(data)
except ConnectionAbortedError:
player.stop()
if player.server == None:
player.queue_thread.stop()
print("server has been closed")
print("closing program")
exit()
print("program closed")
player.send是常规的TcpIp客户端发送。
protocol.KA()编码(" H&#34):
def encode(self, data):
return self._pack_string(self.msg_id, data)
def _pack_string(self, msg_id, s):
s = bytes(s, 'utf-8')
l = len(s)
print(str(l) +" " + str(s))
data = struct.pack("II%ds" %l, msg_id, l, s)
return data
问题是:
错误是什么意思?我该如何解决?
谢谢
(KA = Keep Alive。如果您需要更多代码告诉我)
(打印结果:1 b' h')