We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6852d3c commit 2c7c60aCopy full SHA for 2c7c60a
vxi11/rpc.py
@@ -232,21 +232,20 @@ def recvfrag(sock):
232
x = struct.unpack(">I", header[0:4])[0]
233
last = ((x & 0x80000000) != 0)
234
n = int(x & 0x7fffffff)
235
- frag = b''
236
- while n > 0:
237
- buf = sock.recv(n)
+ frag = bytearray()
+ while len(frag) < n:
+ buf = sock.recv(n - len(frag))
238
if not buf: raise EOFError
239
- n = n - len(buf)
240
- frag = frag + buf
+ frag.extend(buf)
241
return last, frag
242
243
def recvrecord(sock):
244
- record = b''
+ record = bytearray()
245
last = 0
246
while not last:
247
last, frag = recvfrag(sock)
248
- record = record + frag
249
- return record
+ record.extend(frag)
+ return bytes(record)
250
251
252
# Client using TCP to a specific port
0 commit comments