-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
std.net: use send/recv for streams, support vectorized io on windows
The primary goal of this change is to use `send` and `recv` for network streams, this also enables passing per-message flags like `MSG_NOSIGNAL` instead of installing a SIGPIPE handler. - Alongside using recv and send, windows now uses WSARecvFrom and WSASendTo for readv and writev. This enables vectorized network I/O on windows. Introduces a mostly platform agnostic iovec as `std.net.iovec` and `std.net.iovec_const`. This provides a singular interface to vectorized network I/O on windows and posix. - The only problem this introduces is windows using `u32` for lengths and posix using `usize`. This requires any code currently using `usize` to `@intCast` into the length field. - As part of this change, `std.posix.iovec` and `std.windows.ws2_32.WSABUF` now use `.ptr` and `.len` instead of their posix/windows specific names. Removes std.os.windows.ws2_32.WSARecvMsg, as it is not present in ws2_32.dll and must be fetched via WSAIoctl. - The `sendto` and `recvfrom` wrappers around `WSASendTo` and `WSARecvFrom` have been removed from `std.os.windows`. These functions are already provided by `ws2_32` and are not needed. A os-agnostic IoVec struct (re #7699) would likely be more convienent to use, but I could not design an interface that both works well and is reasonable to interact with. A potential problem this PR introduces is passing `WSABUF_const` to `WSASendTo` and `WSASend` is that this type doesn't actually exist in windows. Windows makes no guarantees that the buffers will not be modified. This enables the "general client/server API coverage" test on windows. The comment on the skip claims that the test was never passing, however during my tests the test passed 100% of the time.
- Loading branch information
1 parent
b87baad
commit 74a9a6a
Showing
24 changed files
with
433 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.