Fix building ExportedConnection on Windows #80
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.
The
<unistd.h>
header isn't available on Windows. Thedup
function is deprecated1 and apparently also not the correct function here.On Windows
uv_fileno
currently returns aSOCKET
2 cast intouv_os_fd_t
3. Contrary to many other handles this handle type can't be duplicated usingDuplicateHandle
4.WSADuplicateSocket
has to be used instead. As documented an actualSOCKET
has to be constructed fromWSAPROTOCOL_INFOW
. The parameters are taken from the struct, except forg
anddwFlags
which were taken from libuv's implementation5.Error handling was omitted like with
uv_fileno
anddup
already.Also changed the type of
fd
to whatuv_tcp_open
expects which isSOCKET
instead ofint
on Windows.Footnotes
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-dup-dup2 ↩
https://github.com/libuv/libuv/blob/2f1614b1286f53b3b2ab96a15a525cb25462ba9a/include/uv/win.h#L456 ↩
https://github.com/libuv/libuv/blob/2f1614b1286f53b3b2ab96a15a525cb25462ba9a/src/win/core.c#L689 ↩
https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-duplicatehandle#remarks ↩
https://github.com/libuv/libuv/blob/2f1614b1286f53b3b2ab96a15a525cb25462ba9a/src/win/tcp.c#L1281-L1282 ↩