summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/socket.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/socket.py b/server/socket.py
index b184d4b..ce505e3 100644
--- a/server/socket.py
+++ b/server/socket.py
@@ -109,10 +109,10 @@ class JsonClientSocket(SocketHandler):
self.address = address
socket.setblocking(False)
self.status = 0 # registering
- self.receiving_header = True
- self.buffer = []
+ self.receiving_header = True # whether we're receiving the length of the next packet, or the packet itself
+ self.buffer = [] # chunks of the next packet (header or body)
self.received_length = 0 # the cumulative length of strings in buffer
- self.body_length = 0 # the length of the next packet, given in the header
+ self.body_length = 0 # the length of the next packet, which was given in the header
self._read_lock = threading.Lock()
self._write_lock = threading.Lock()
@@ -144,7 +144,7 @@ class JsonClientSocket(SocketHandler):
offset = i + 1
self.receiving_header = False
continue
- elif (self.received_length + N - offset) <= self.body_length:
+ elif (self.received_length + N - offset) >= self.body_length:
if self.received_length == 0:
# an optimized case
s = data[offset:offset+self.body_length]