Skip to content

Commit

Permalink
use given size parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
BarVaserman authored Mar 31, 2022
1 parent 7a860eb commit a5f3dd1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rpcclient/rpcclient/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ def sendall(self, buf: bytes):
def recv(self, size: int = CHUNK_SIZE) -> bytes:
""" recv(fd, buf, size, 0) at remote. read man for more details. """
with self._client.safe_malloc(size) as chunk:
err = self._client.symbols.recv(self.fd, chunk, self.CHUNK_SIZE).c_int64
err = self._client.symbols.recv(self.fd, chunk, size).c_int64
if err < 0:
raise BadReturnValueError(f'read failed for fd: {self.fd}')
return chunk.peek(err)

def recvall(self, size: int) -> bytes:
""" recv at remote until all buffer is received """
buf = b''
with self._client.safe_malloc(self.CHUNK_SIZE) as chunk:
with self._client.safe_malloc(size) as chunk:
while len(buf) < size:
err = self._client.symbols.read(self.fd, chunk, self.CHUNK_SIZE).c_int64
err = self._client.symbols.read(self.fd, chunk, size).c_int64
if err <= 0:
raise BadReturnValueError(f'read failed for fd: {self.fd}')
buf += chunk.peek(err)
Expand Down

0 comments on commit a5f3dd1

Please sign in to comment.