Some improvements to the API surface to actually handle some more error
cases correctly and fix typing.
Co-authored-by: Cory Benfield <lukasa@apple.com>
`Posix.*` cannot be used on Windows. Sockets and (file) descriptors are
in entirely different namespaces, and will result in an invalid
operation.
Co-authored-by: Cory Benfield <lukasa@apple.com>
This removes the testing-only API of `poll` on Windows which does not
have a semantic compatible poll.
Co-authored-by: David Evans <d.evans@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
`ssize_t` is not a standard type and does not have a portable Swift
spelling. Use `size_t` which is compatible in size, but is signed
instead. This is needed in order to be compatible to more standard
conforming environments like Windows.
Motivation:
sendmsg is more powerful - this is paving the way for
Explicit Congestion Notifications to be sent.
Modifications:
Replace the sendto system call with sendmsg up to DatagramChannel.
Result:
Sendmsg will be used to send UDP data.
Motivation:
When attempting to obtain metadata about a read, we need to use recvmsg
in order to obtain that data. While we're using recvmmsg for vector
reads right now, our scalar reads use recvfrom, which does not provide
us with that metadata.
While we're not extracting metadata right now, we may well do so in
future, so we can apply it now.
Modifications:
- Move recvfrom usage to recvmsg.
Result:
We'll be able to extend recvmsg to extract metadata.
Motivation:
Split out the internal implied BSD socket API code to allow alternative implementations of these interfaces on other platforms.
Modifications:
- Split the code apart.
- Provide POSIX and Windows implementations of the BSD socket API.
Result:
Should be easier to run NIO unmodified on Windows.