Right now, reliable_recv() reads 1024 bytes and blindly calls json.loads(). TCP is a byte stream, not a message boundary protocol. If two JSON payloads arrive in the same 1024-byte chunk, json.loads() crashes and we spin into an infinite ValueError loop.
The Fix:
Prefix every outgoing message with a 4-byte length header (use struct.pack).
On receive, read exactly 4 bytes to get the payload length N.
Read exactly N bytes into a buffer, then cleanly json.loads() it.
Right now, reliable_recv() reads 1024 bytes and blindly calls json.loads(). TCP is a byte stream, not a message boundary protocol. If two JSON payloads arrive in the same 1024-byte chunk, json.loads() crashes and we spin into an infinite ValueError loop.
The Fix:
Prefix every outgoing message with a 4-byte length header (use struct.pack).
On receive, read exactly 4 bytes to get the payload length N.
Read exactly N bytes into a buffer, then cleanly json.loads() it.