24 lines
596 B
Python
24 lines
596 B
Python
#client
|
|
import socket
|
|
import threading
|
|
|
|
from utils import receive_messages, send_messages
|
|
|
|
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
client_socket.connect(("localhost", 9999))
|
|
|
|
pseudo = input("Choisissez votre pseudo : ")
|
|
client_socket.send(pseudo.encode())
|
|
|
|
print(f"Connecté au chat en tant que {pseudo} !\n")
|
|
|
|
thread_recv = threading.Thread(target=receive_messages, args=(client_socket,))
|
|
thread_send = threading.Thread(target=send_messages, args=(client_socket,))
|
|
|
|
thread_recv.start()
|
|
thread_send.start()
|
|
|
|
thread_recv.join()
|
|
thread_send.join()
|
|
|
|
print("Chat terminé.") |