Notably, the timeout becomes provided by the general-purpose Batch API rather than being special-purposed.
Also implements the operation for Windows in std.Io.Threaded as well as implementing netSend for Windows.
Release Notes
Windows Applications and ws2_32.dll Dependency
Due to the way std.Io currently works, Windows applications will be more likely to inadvertently drag in a dependency on networking, and therefore ws2_32.dll even if no networking functionality is used. There are ways to work around this problem:
- Use
std.optionstonetworkingtofalsein the root source file. This causes allstd.Ionetworking functions to returnerror.NetworkDownand prevents accidental dependency onws2_32.dll. - Explicitly add the
-lws2_32dependency via CLI orlinkSystemLibraryin build.zig script. - Avoid taking a detour through object file format by compiling Zig source files directly into executables (related: #31425)
This is a breaking change from 0.15.x. This has the same root cause as #31421 but it's extra problematic due to the ws2_32.dll dependency.
In the future, here are some more options to possibly explore:
- networking via bypassing the Winsock API and using \Device\Afd directly (see #31131)
- enhanced frontend compiler optimizations leading to pruning unused DLL dependencies, including in Debug mode.
std.Io.operateTimeout
The function std.Io.operateTimeout is provided to conveniently perform any single Io.Operation with ability to fail with error.Timeout after a specified duration or at a specified timestamp. This function is implemented via the lower-level Io.Batch.awaitConcurrent API.
Follow-up Work
- std.Io.Uring Batch implementation
- std.Io.Dispatch implementation
- move almost all the file and networking functionality to be based on Operation and support Batch