vegbesserungen

This commit is contained in:
Michael S. 2023-12-01 14:34:20 +01:00
parent 11396ef2cf
commit a3197dbc28
2 changed files with 8 additions and 3 deletions

View file

@ -14,11 +14,13 @@ if nickname == "":
run = True
def receive_message(sock):
print_lock = threading.Lock()
while run:
try:
msg = sock.recv(1024).decode('utf-8')
if not msg:
break
with print_lock:
print(f"\r{msg}\n", end='', flush=True)
except:
break

View file

@ -16,8 +16,11 @@ def send_to_all(conn, msg):
try:
client.sendall(msg.encode('utf-8'))
except BrokenPipeError:
print("Broken Pipe Error")
pass
print("Verbindung verloren.")
with lock:
clients.remove((conn, nick))
conn.close()
break
def handle_client(conn, addr):
nick = conn.recv(1024).decode('utf-8')