Msg receiving debug prints

This commit is contained in:
artem30801@gmail.com
2019-03-29 20:02:55 +03:00
parent a57a70a38e
commit 7fc61bbe19
2 changed files with 4 additions and 0 deletions

View File

@@ -92,6 +92,7 @@ def recive_all(n):
data = b''
while len(data) < n:
packet = clientSocket.recv(min(n - len(data), BUFFER_SIZE))
print("Receiving packet {}; full data is {}".format(packet, data))
if not packet:
return None
data += packet
@@ -101,6 +102,7 @@ def recive_all(n):
def recive_message():
raw_msglen = recive_all(4)
if not raw_msglen:
print("No valid msg")
return None
msglen = struct.unpack('>I', raw_msglen)[0]
msg = recive_all(msglen)

View File

@@ -246,6 +246,7 @@ class Client:
data = b''
while len(data) < n:
packet = self.socket.recv(min(n - len(data), Server.BUFFER_SIZE))
print("Receiving packet {}; full data is {}".format(packet, data))
if not packet:
return None
data += packet
@@ -254,6 +255,7 @@ class Client:
def _receive_message(self):
raw_msglen = self._receive_all(4)
if not raw_msglen:
print("No valid msg")
return None
msglen = struct.unpack('>I', raw_msglen)[0]
msg = self._receive_all(msglen)