From bd94f0e73cd14fdd21d69b0e78550f08013f4f51 Mon Sep 17 00:00:00 2001 From: DoronZ Date: Sat, 2 Apr 2022 22:30:46 +0300 Subject: [PATCH] network: Socket: make size field in `send()` an optional argument --- src/rpcclient/rpcclient/network.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/rpcclient/rpcclient/network.py b/src/rpcclient/rpcclient/network.py index 0eac9ddc..ce538033 100644 --- a/src/rpcclient/rpcclient/network.py +++ b/src/rpcclient/rpcclient/network.py @@ -29,8 +29,16 @@ def _deallocate(self): if fd < 0: raise BadReturnValueError(f'failed to close fd: {fd}') - def send(self, buf: bytes, size: int) -> int: - """ send(fd, buf, size, 0) at remote. read man for more details. """ + def send(self, buf: bytes, size: int = None) -> int: + """ + send(fd, buf, size, 0) at remote. read man for more details. + + :param buf: buffer to send + :param size: If None, use len(buf) + :return: how many bytes were sent + """ + if size is None: + size = len(buf) n = self._client.symbols.send(self.fd, buf, size, 0).c_int64 if n < 0: raise BadReturnValueError(f'failed to send on fd: {self.fd}')