diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 4d5073f659..38f6199f46 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -11025,7 +11025,11 @@ fn openSocketWsa( ) !ws2_32.SOCKET { const mode = posixSocketMode(options.mode); const protocol = posixProtocol(options.protocol); - const flags: u32 = ws2_32.WSA_FLAG_NO_HANDLE_INHERIT; + // WSA_FLAG_OVERLAPPED is chosen here because without this different + // threads cannot use the same open socket handle. + // TODO: the below code needs to use the AlertableSyscall mechanism instead in + // order to make cancelation work. + const flags: u32 = ws2_32.WSA_FLAG_OVERLAPPED | ws2_32.WSA_FLAG_NO_HANDLE_INHERIT; var syscall: Syscall = try .start(); while (true) { const rc = ws2_32.WSASocketW(family, @bitCast(mode), @bitCast(protocol), null, 0, flags);