Skip to content

Commit

Permalink
network: Socket: make size field in send() an optional argument
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Apr 2, 2022
1 parent 4212871 commit bd94f0e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/rpcclient/rpcclient/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down

0 comments on commit bd94f0e

Please sign in to comment.