Skip to content

Commit 79cdc5c

Browse files
committed
Default to 4K receive buffer size
Change the _sync method so that when no specific size is requested it fetches up to 4096 bytes instead of 1 byte at a time from the operating system. It's not clear what the reason was for setting it 1 byte. It was introduced in pymodbus commit: 9d2c864 Patch: 3b490fe But there's no rationale there for setting it to 1 byte specifically. While it may have been to handle some obscure operating system with a poor network stack implementation this should have been documented, as it is written it comes across as that the implementer didn't understand how the TCP/stream socket networking API works. Note that https://docs.python.org/3/library/socket.html does not contain a full description on the socket.recv method; see also pydoc for socket.socket.recv.
1 parent 5f5b427 commit 79cdc5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pymodbus/client/sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ def _recv(self, size):
261261

262262
timeout = self.timeout
263263

264-
# If size isn't specified read 1 byte at a time.
264+
# If size isn't specified read up to 4096 bytes at a time.
265265
if size is None:
266-
recv_size = 1
266+
recv_size = 4096
267267
else:
268268
recv_size = size
269269

0 commit comments

Comments
 (0)