Fix Windows build with craft
The only failing test is transmittest and I cannot understand how to fix it. I figured out that things go in this order:
- The UTPServer creates a ServerSocket and binds it to 0.0.0.0:50000
- The test asks UTPServer to connect to 127.0.0.1:50000
- The UTPServer creates Connection object and tells it to start connecting to the server
- The Connection tells UTPServer to send SYN packet to Connection
- When ServerSocket is ready to write, it sends the packet to Connection
- ServerSocket (wrapper around Socket) calls Winsocks
sendto
which sometimes gives the errorWSAEFAULT
The
buf
orto
parameters are not part of the user address space, or thetolen
parameter is too small.
see https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-sendto.
I ran the test multiple times and forced the sendto
to use the same parameters for each run (the only difference being the ServerSocket's fd) yet still the test sometimes passes and fails. Even if the fd happens to be the same value, the test can fail pass or fail. I have even witnessed sendto
return -1 (indicating an error), but WSAGetLastError
returns 0 (indicating no error).
On the off chance that the does does pass, the sendto
reports that it sent 20 bytes, despite the buffer containing 16 bytes. I don't know much about networking but this also seems a bit suspicious to me.