small reorganization to old client/server, client fixed and sending messages to server

This commit is contained in:
Xevion
2021-01-08 15:06:52 -06:00
parent 4dc14d118b
commit 390595c0e2
5 changed files with 44 additions and 58 deletions

7
helpers.py Normal file
View 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)