我正在向客户端发送消息,但客户端不会停止发送垃圾邮件服务器.pyserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM)hostname = socket.gethostname()hostip = socket.gethostbyname(hostname)port = 462server.bind((hostname, port))server.listen(1)print((hostip, port))client, address = server.accept()print("New connection!: ", address)while True: data = input("Do something:") if data == "help": print("test: 'test'") input("Click ENTER to continue") elif data == "test": client.send("test".encode('ascii')) else: continue客户端.pys = socket.socket(socket.AF_INET, socket.SOCK_STREAM)host = socket.gethostname()port = 462s.connect(('', port))data = s.recv(1024)while True: if data.decode('ascii') == "test": print(data.decode('ascii')) else: continue
添加回答
举报
0/150
提交
取消