我正在向客戶端發送消息,但客戶端不會停止發送垃圾郵件服務器.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
Python 套接字不會阻止垃圾郵件
慕碼人8056858
2021-09-14 16:26:13