def worker_send(self):
while True:
msgbody = input('say sth: ')
msgbody = msgbody.rstrip()
msgbody_len = len(msgbody)
msgbody_len = socket.ntohs(msgbody_len)
msgbody_len = struct.pack('h', msgbody_len)
send_msg = action + peer_id + msgbody_len + msgbody.encode('utf-8')
self.send(send_msg)
评论列表
文章目录