import socket HOST = "127.0.0.1" PORT = 50007 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client: client.connect((HOST, PORT)) with client.makefile("rwb") as flux: while True: message = input("Votre message (quit pour quitter) : ") flux.write((message + "\n").encode("utf-8")) flux.flush() reponse = flux.readline() if not reponse: print("Le serveur a fermé la connexion.") break print(reponse.decode("utf-8").rstrip()) if message.lower() == "quit": break