Skip to content

Commit

Permalink
Update repl_server.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Apr 26, 2023
1 parent 2c5ba70 commit 03a30a4
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/scripts/repl_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,10 @@ def __init__(self, socket):

def recv_msg(self):
self._read_buf.clear()
# requires at least 3 bytes as metadata
while len(self._read_buf) < 3:
self._read_buf.extend(self.socket.recv(1024))

self._read_buf.extend(self.socket.recv(3))
inst = int.from_bytes(self._read_buf[:1], 'big')
data_len = int.from_bytes(self._read_buf[1:3], 'big')

# until all data has been read
while len(self._read_buf) < 3 + data_len:
self._read_buf.extend(self.socket.recv(1024))
self._read_buf.extend(self.socket.recv(data_len))

return (inst, self._read_buf[3:].decode())

Expand Down

0 comments on commit 03a30a4

Please sign in to comment.