Skip to content

Sockets: align the WinSocket backends' send() semantics - #1829

Merged
Mysticial merged 1 commit into
mainfrom
f4-win-send-residuals
Nov 2, 2026
Merged

Mysticial merged 1 commit into
mainfrom
f4-win-send-residuals

Conversation

@pa-devbot

Copy link
Copy Markdown
Collaborator

Follow-up to the send()-deadline work (#1825/#1826): the two remaining send() inconsistencies between the WinSocket backend and the POSIX/Qt backends (F4 residuals from the TCP audit).

What changed

  • WinSocket client (ClientSocket_WinSocket.cpp): send() returned on the first partial ::send() call, while POSIX/Qt loop until everything is written, the deadline elapses, or close() cancels the send. It now advances and loops like them. The loop condition already re-checks the deadline and the state each iteration, so deadline/cancel behavior is unchanged; only "give up on the first partial block" goes away. In practice this only affects payloads that don't fit in one ::send() call (the 4096-byte protocol frames always did).
  • WinSocket server (ServerSocket_WinSocket.cpp): send() passed the raw payload length to ::send(), which takes an int — a payload > 2 GiB wrapped the length negative. It now chunks at 1 GiB, the same BLOCK_SIZE the WinSocket client already used.

Testing

No new test: the alignment is behavior-preserving for everything the existing tests exercise, and the 2 GiB case would need a 2 GiB allocation just to hit the cast. Both changes are covered by the existing deadline/send-close tests in CI (Windows runs the WinSocket backend). No changes to the send/close race, the deadline tests, or the POSIX/Qt backends.

Two residuals of the cross-backend send() inconsistency:

- The WinSocket client returned on the first partial ::send() call
  (mid-block), while the POSIX and Qt backends keep sending until
  everything is written, the deadline elapses, or close() cancels the
  send. It now advances and loops like them; the loop condition
  re-checks the deadline and the state each iteration, so the
  cancellation and deadline behavior is unchanged.
- The WinSocket server passed the raw payload length to ::send(),
  which takes an int: a payload larger than 2 GiB wrapped the length
  negative. It now chunks the send at 1 GiB, the same cap the
  WinSocket client already uses.
@Mysticial
Mysticial merged commit d909fe3 into main Nov 2, 2026
6 of 7 checks passed
@Mysticial
Mysticial deleted the f4-win-send-residuals branch November 2, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants