mirror of
https://github.com/Xevion/tcp-chat.git
synced 2025-12-06 09:16:40 -06:00
small reorganization to old client/server, client fixed and sending messages to server
This commit is contained in:
7
helpers.py
Normal file
7
helpers.py
Normal file
@@ -0,0 +1,7 @@
|
||||
HEADER_LENGTH = 10
|
||||
|
||||
|
||||
def prepare(message: str, encoding='ascii') -> bytes:
|
||||
"""Prepares a message for sending through a socket by adding a proper header and encoding it."""
|
||||
header = f'{len(message):<{HEADER_LENGTH}}'
|
||||
return (header + message).encode(encoding)
|
||||
Reference in New Issue
Block a user