unix/modsocket: Add "sendall" method to socket class. #17369
+109
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an implementation for "socket.sendall" to the Unix port.
Right now the implementation is a wrapper over a single "socket.send" call, since it wasn't possible to let "socket.send" perform a partial transfer. With no partial transfers it is not possible to have a testable implementation following the expected behaviour, so a single send operation is done and OSErr(EINTR) is raised if a partial transfer occurs.
The discussion for the issue linked to this PR contains more information about the efforts made to let partial transfers happen.
This fixes #16803.
Testing
A new test is introduced to exercise
socket.sendall
, calledtests/multi_net/tcp_sendall.py
. This could have been folded intotests/multi_net/tcp_data.py
, but the Zephyr port doesn't have asocket.sendall
implementation.Trade-offs and Alternatives
There's a modest size increase. The footprint increase could have been smaller if
socket.sendall
was aliased tosocket.send
like the CC3200 port does, but then the behaviour would be slightly incompatible with CPython (socket.sendall
is supposed to returnNone
, not the sent bytes count).