aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/windows/ws2_32.zig
AgeCommit message (Collapse)Author
2025-10-29std: fix definition of ws2_32.GetAddrInfoExWAndrew Kelley
There was a missing parameter.
2025-10-29std.Io.Threaded: delete Windows implementation of if_nametoindexAndrew Kelley
Microsoft documentation says "The if_nametoindex function is implemented for portability of applications with Unix environments, but the ConvertInterface functions are preferred." This was also the only dependency on iphlpapi.
2025-10-29std.Io.Threaded: implement netLookup for WindowsAndrew Kelley
2025-10-29std.os.windows.ws2_32: remove 'A' variantsAndrew Kelley
2025-10-29std.Io.Threaded: implement netListen for WindowsAndrew Kelley
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2024-11-02std.os.windows: Deprecate WINAPI in favor of CallingConvention.winapi.Alex Rønne Petersen
2024-07-19std.c reorganizationAndrew Kelley
It is now composed of these main sections: * Declarations that are shared among all operating systems. * Declarations that have the same name, but different type signatures depending on the operating system. Often multiple operating systems share the same type signatures however. * Declarations that are specific to a single operating system. - These are imported one per line so you can see where they come from, protected by a comptime block to prevent accessing the wrong one. Closes #19352 by changing the convention to making types `void` and functions `{}`, so that it becomes possible to update `@hasDecl` sites to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up removing some duplicate logic and update some bitrotted feature detection checks. A handful of types have been modified to gain namespacing and type safety. This is a breaking change. Oh, and the last usage of `usingnamespace` site is eliminated.
2024-03-21std.os.windows: add POLL.IN and POLL.OUTMichael Ortmann
2023-11-22add missing timeval structMikko Kaihlavirta
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-01-19Make `res` nullable in `getaddrinfo`Jarred Sumner
2023-01-02remove the experimental std.x namespaceAndrew Kelley
Playtime is over. I'm working on networking now.
2022-12-11std: fix compile error bitrotAndrew Kelley
These were revealed in an earlier commit in this branch that removed a workaround disabling Windows std lib files from being tested.
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-09-29std: Replace use of stage1 function pointersominitay
2022-06-07add const to msghdr_const iov and control pointersJonathan Marler
alongside the typical msghdr struct, Zig has added a msghdr_const type that can be used with sendmsg which allows const data to be provided. I believe that data pointed to by the iov and control fields in msghdr are also left unmodified, in which case they can be marked const as well.
2021-12-19stage1, stage2: rename c_void to anyopaque (#10316)Isaac Freund
zig fmt now replaces c_void with anyopaque to make updating code easy.
2021-09-16Set the Storage socket sizes to be system definedStephen Gregoratto
Some systems (Solaris, OpenBSD, AIX) change their definitions of sockaddr_storage to be larger than 128 bytes. This comment adds a new constant in the `sockaddr` that defines the size for every system. Fixes #9759
2021-09-14Remove WIN16 version of WSAOVERLAPPED. Use LPWSAOVERLAPPED_COMPLETION_ROUTINETravis Martin
2021-09-12os: usingnamespace fixes for std.x.os.Socket and std.os.TCPKenta Iwasaki
Extract existing constants to do with TCP socket options into a 'TCP' namespace. Export 'MSG' and 'TCP' from std.os.{linux, windows} into std.c. Fix compile errors to do with std.x.os.Socket methods related to setting TCP socket options. Handle errors in the case that an interface could not be resolved in an IPv6 address on Windows. Tested using Wine with the loopback interface disabled. Have all instantiations of std.x.os.Socket on Windows instantiate an overlapped socket descriptor. Fixes the '1ms read timeout' test in std.x.net.tcp.Client. The test would previously deadlock, as read timeouts only apply to overlapped sockets. Windows documentation by default recommends that most instantiations of sockets on Windows be overlapped sockets (s.t. they may operate in both blocking or nonblocking mode when operated with WSA* syscalls). Refer to the documentation for WSASocketA for more info.
2021-09-01std: reorganization that allows new usingnamespace semanticsAndrew Kelley
The proposal #9629 is now accepted, usingnamespace stays but no longer puts identifiers in scope.
2021-09-01std.os.windows: reorg to avoid `usingnamespace`Andrew Kelley
Down to 19 uses of `usingnamespace`.
2021-09-01std.os: more reorganization effortsAndrew Kelley
* std lib tests are passing on x86_64-linux with and without -lc * stage2 is building from source on x86_64-linux * down to 38 remaining uses of `usingnamespace`
2021-09-01std: reorganize std.c to eliminate `usingnamespace`Andrew Kelley
Behavior tests pass on x86_64-linux with -lc
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-06-01os: make msghdr, msghdr_const, and sockaddr_storage backwards-compatibleKenta Iwasaki
`msghdr` and `msghdr_const` definitions have been added back the way they were in std.os. std.os.sendmsg has also been modified to accept a msghdr_const again to ensure backwards-compatibility with this PR. Underneath the hood, std.os.sendmsg will @ptrCast the provided msghdr_const into a std.x.os.Socket.Message. `sockaddr_storage` definitions have been added back the way they were in std.os, except that it now simply aliases std.x.os.Socket.Address.Native.Storage as all of std.x.os.Socket.Address.Native.Storage's fields are equivalent to the fields that were previously defined for std.x.os.bits.sockaddr_storage. std.x.os.Socket.sendMessage now no longer is a stub that aliases std.os.sendmsg, but instead calls and handles errors from std.os.system.sendmsg directly. Addresses feedback to urge backwards compatibility from @andrewrk.
2021-06-01os: `sockaddr_storage` -> `std.x.os.Socket.Address.Native.Storage`Kenta Iwasaki
2021-06-01x/io, x/os: async i/o reactor, cross-platform socket syscalls and bitslithdew
Cross-platform versions of msghdr, sendmsg, recvmsg, linger, and iovec were provided based on findings from glibc, musl, and Microsoft's documentation. Implemented initial Reactor interface for epoll (linux) which wraps around I/O reactor subsystems such as epoll, kqueue, select, etc. across different platforms. The Reactor interface allows for driving async I/O in Zig applications. A test was added for the Reactor interface to drive a TCP client/listener socket pair. A greatest-common-subset of possible socket initialization flags (close socket on exec syscalls, initialize socket to be non-blocking) were implemented. A test was added for using sendmsg/recvmsg syscalls across different platforms for a TCP client/listener socket pair.
2021-05-12Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * lib/std/os/linux.zig * lib/std/os/windows/bits.zig * src/Module.zig * src/Sema.zig * test/stage2/test.zig Mainly I wanted Jakub's new macOS code for respecting stack size, since we now depend on it for debug builds able to pass one of the test cases for recursive comptime function calls with `@setEvalBranchQuota`. The conflicts were all trivial.
2021-05-10std/os/windows/ws2_32: add missing FIONBIO constantlithdew
2021-05-10x/os/socket, std/os/windows: implement loading winsock extensionslithdew
Implement loading Winsock extensions. Add missing Winsock extension GUID's. Implement readVectorized() for POSIX sockets and readVectorized() / writeVectorized() for Windows sockets. Inverse how mixins are used to implement platform-independent syscalls for the std.x.os.Socket abstraction. This cleans up the API as suggested by @komuw.
2021-05-10x/os, x/net, os:, fix typos/errors, add missing constants/docslithdew
Add missing constants to ws2_32 such as SIO_BASE_HANDLE. Made all declared constants in ws2_32 comptime_int, and fixed a few broken constants (i.e. GUID's). Fixed a few syscalls not having callconv(WINAPI) in ws2_32. Fixed a typo in std.x.net.tcp.Client. Removed unnecessary @alignCast's for socket addresses in std.x.net.Socket. Added a warning on using timeout methods for std.x.net.Socket. Fixed compilation error spotted by CI in std.os that references std.os.windows.ws2_32.SD_RECEIVE. Renamed std.x.os.Socket.setOption()'s parameter `name: u32` to `code: u32`.
2021-05-10std/os, x/os/socket: windows support, socket helpers, getpeername()lithdew
Socket I/O methods such as read, readv, write, writev, send, recv, sendmsg, recvmsg have been generalized to read(buf, flags), write(buf, flags), readVectorized(vectors, flags), and writeVectorized(vectors, flags). There is still some work left to be done abstracting both readVectorized and writeVectorized properly across platforms, which is work to be done in a future PR. Support for setting the linger timeout of a socket, querying the remote address of a socket, setting whether or not keep-alive messages are to be sent through a connection-oriented socket periodically depending on host operating system settings has been added. `std.io.Reader` and `std.io.Writer` wrappers around `Socket` has been implemented, which wrap around Socket.read(buf, flags) and Socket.write(buf, flags). Both wrappers may be provided flags which are passed to Socket.read / Socket.write accordingly. Cross-platform support for `getpeername()` has been implemented. Windows support for the new `std.x.os.Socket` has been implemented. To accomplish this, a full refactor of `std.os.windows.ws2_32` has been done to supply any missing definitions and constants based on auto-generated Windows syscall bindings by @marler8997. `std.x.net.TCP.Listener.setQuickACK` has been moved to `std.x.net.TCP.Client.setQuickACK`. Windows support for resolving the scope ID of an interface name specified in an IPv6 address has been provided. `sockaddr_storage` definitions have been provided for Windows, Linux, and Darwin. `sockaddr_storage` is used to allocate space before any socket addresses are queried via. calls such as accept(), getsockname(), and getpeername(). Zig-friendly wrappers for GetQueuedCompletionStatusEx(), getpeername(), SetConsoleCtrlHandler(), SetFileCompletionNotificationModes() syscalls on Windows have been provided. Socket.setOption() was provided to set the value of a socket option in place of os.setsockopt. Socket.getOption() will be provided in a future PR. There is still further work to be done regarding querying socket option values on Windows, which is to be done in a subsequent PR.
2021-04-22std: fix compile errors caught by stage2 AstGenAndrew Kelley
* `comptime const` is redundant * don't use `extern enum`; specify a tag type. `extern enum` is only when you need tags to alias. But aliasing tags is a smell. I will be making a proposal shortly to remove `extern enum` from the language. * there is no such thing as `packed enum`. * instead of `catch |_|`, omit the capture entirely. * unused function definition with missing parameter name * using `try` outside of a function or test
2020-12-31Year++Frank Denis
2020-11-30add std.os.shutdown function for socketsJonathan Marler
2020-11-19Update code to not use unsupported calling conventions for targetTadeo Kondrak
2020-10-27std: Add basic smoke test for net functionalityLemonBoy
2020-10-22Merge branch 'improve-windows-networking'Andrew Kelley
of https://github.com/BarabasGitHub/zig into BarabasGitHub-improve-windows-networking Conflicts: lib/std/os.zig This commit resolves conflicts with the changes to std.os which removed the EAGAIN error handling interactions with the event loop. The solution to the conflict was to apply EAGAIN => return error.WouldBlock into the improved windows networking branch.
2020-10-06Update zig files for opaque type syntaxTadeo Kondrak
2020-09-10implement poll for windows with WSAPoll (only available on vista and higher)Bas van den Berg
2020-09-08change socklen_t to u32 and add appropriate casts when calling WSABas van den Berg
2020-09-08Merge branch 'master' into improve-windows-networkingBas
2020-09-03update uses of deprecated type field accessVexu
2020-09-03os.send(to) and os.recv(from) functions made to work on windows.Bas van den Berg
2020-09-02Made some changes and additions to the networking to make it work on windows.Bas van den Berg
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-06-20zig fmtAndrew Kelley