Skip to content

Commit

Permalink
Add newline to end of client message
Browse files Browse the repository at this point in the history
  • Loading branch information
JonneSaloranta committed Mar 18, 2024
1 parent bdc657b commit 80d9fe3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ def handle_client(client):
message = client.recv(1024)
if not message:
raise ConnectionError("Client disconnected")

# add newline to the end of the message
decoded_message = message.decode('utf-8')
decoded_message = decoded_message.strip() + '\n'
broadcast(decoded_message.encode('utf-8'))
print(f"Message from {client.getpeername()}: {decoded_message}")
except ConnectionError:
Expand Down

0 comments on commit 80d9fe3

Please sign in to comment.