Closed mochalins closed 4 months ago
Edit: Just realized that actually the style guide suggests aiming for a line length of 100... I'll make adjustments here!
Can you please split that into two PRs, one that does the styleguide changes, and one that does the semantic changes?
Also can you explain why error.ConnectedTimedOut
is equivalent to error.WouldBlock
?
Can you please split that into two PRs, one that does the styleguide changes, and one that does the semantic changes?
Will do!
Also can you explain why
error.ConnectedTimedOut
is equivalent toerror.WouldBlock
?
This was actually in the existing custom implementations of the Windows socket functions. AFAICT, the POSIX socket implementations return error.WouldBlock
despite not configuring the sockets to be asynchronous and only specifying a timeout. In the same situations, the Windows sockets return error.ConnectedTimedOut
, and thus I believe the existing implementation wrapped both error.WouldBlock
and error.ConnectedTimedOut
from Windows sockets to just error.WouldBlock
.
As I am not deeply familiar with Windows sockets (and unfortunately do not currently have access to a Windows testing environment), I'm open to any feedback in regards to how this should change.
Okay, sounds reasonable. But can you move the error mapping code into a common function explaining this?
Okay, sounds reasonable. But can you move the error mapping code into a common function explaining this?
In the semantic changes split out into #88, recvfrom
is maintained as a separate Windows extern
-wrapped function to avoid libc
linking dependency, as the std.posix.recvfrom
Windows implementation relies on an extern "c" fn recvfrom
rather than extern "ws2_32" fn recvfrom
.
In so doing, only one function connect
now needs this error.ConnectedTimedOut
-> error.WouldBlock
handling, so I did not make a separate function. However, I did add a note explaining the behavior and also remarked that recvfrom
uses similar handling.
Reduce custom types and functions, preferring existing definitions in
std
. Standardize line lengths to idiomatic ~80~ 100 characters. Clean up of someTODO
comments.The
socket
function remains separate from thestd.posix.socket
implementation; however, thestd
implementation translates POSIXSOCK.NONBLOCK
/SOCK.CLOEXEC
to the Windows-specific implementation usingioctl
, and thus there appears to be reasonable potential to integrateSOCK.DGRAM
handling directly instd
. This would enable usingstd.posix.socket
directly.Resolves #44.