import socket

HOST = "127.0.0.1"
PORT = 65432

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
    print(f"Connecté au serveur {HOST}:{PORT}. Tapez 'bye' pour quitter.")

    while True:
        msg = input("> ")
        s.sendall(msg.encode())
        if msg.lower() == "bye":
            break
        data = s.recv(1024).decode()
        if not data or data.lower() == "bye":
            break
        print(f"[serveur] {data}")

print("Client terminé.")
