From 9125a42d5dfb4a77e7e677e7588899d483221f3f Mon Sep 17 00:00:00 2001 From: zhangxiaoyang Date: Fri, 6 May 2016 16:26:38 +0800 Subject: [PATCH 1/2] fix recv function --- api/python/src/GstoreConnector.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/python/src/GstoreConnector.py b/api/python/src/GstoreConnector.py index 0386e21..2c968d0 100644 --- a/api/python/src/GstoreConnector.py +++ b/api/python/src/GstoreConnector.py @@ -35,15 +35,15 @@ class GstoreConnector: head = self._sock.recv(4) context_len = 0 for i in range(4): - context_len |= (ord(head[i]) << i * 8) + context_len |= (ord(head[i]) & 0xFF) << i * 8 - data = bytearray(context_len) + data = bytearray() recv_len = 0 while recv_len < context_len: chunk = self._sock.recv(1024) data.extend(chunk) recv_len += len(chunk) - return str(data) + return data.rstrip('\x00').decode('utf-8') def _pack(self, msg): data_context = bytearray() From 72aa04e4dcd9515df7ede69518572f94c429a50a Mon Sep 17 00:00:00 2001 From: zhangxiaoyang Date: Fri, 6 May 2016 16:28:41 +0800 Subject: [PATCH 2/2] change recv buffer --- api/python/src/GstoreConnector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/python/src/GstoreConnector.py b/api/python/src/GstoreConnector.py index 2c968d0..2890396 100644 --- a/api/python/src/GstoreConnector.py +++ b/api/python/src/GstoreConnector.py @@ -40,7 +40,7 @@ class GstoreConnector: data = bytearray() recv_len = 0 while recv_len < context_len: - chunk = self._sock.recv(1024) + chunk = self._sock.recv(context_len - recv_len) data.extend(chunk) recv_len += len(chunk) return data.rstrip('\x00').decode('utf-8')