| author | |
| committer | |
| log | 34720da3d0a4a98383639cbedcbe1aa885217ed6 |
| tree | 183937da172d8cacda17a88df9a479bf4f2403ee |
| parent | d0beb4badb9064893133c996b05c0748317adf24 |
Starting from Windows 10 build 17063.2 files changed, 14 insertions(+), 1 deletions(-)
lib/std/net.zig+5-1| ... | @@ -12,7 +12,11 @@ const os = std.os; | ... | @@ -12,7 +12,11 @@ const os = std.os; |
| 12 | const fs = std.fs; | 12 | const fs = std.fs; |
| 13 | const io = std.io; | 13 | const io = std.io; |
| 14 | 14 | ||
| 15 | pub const has_unix_sockets = @hasDecl(os, "sockaddr_un"); | 15 | // Windows 10 added support for unix sockets in build 17063, redstone 4 is the |
| 16 | // first release to support them. | ||
| 17 | pub const has_unix_sockets = @hasDecl(os, "sockaddr_un") and | ||
| 18 | (builtin.os.tag != .windows or | ||
| 19 | std.Target.current.os.version_range.windows.isAtLeast(.win10_rs4) orelse false); | ||
| 16 | 20 | ||
| 17 | pub const Address = extern union { | 21 | pub const Address = extern union { |
| 18 | any: os.sockaddr, | 22 | any: os.sockaddr, |
lib/std/net/test.zig+9| ... | @@ -258,6 +258,15 @@ test "listen on a unix socket, send bytes, receive bytes" { | ... | @@ -258,6 +258,15 @@ test "listen on a unix socket, send bytes, receive bytes" { |
| 258 | if (builtin.single_threaded) return error.SkipZigTest; | 258 | if (builtin.single_threaded) return error.SkipZigTest; |
| 259 | if (!net.has_unix_sockets) return error.SkipZigTest; | 259 | if (!net.has_unix_sockets) return error.SkipZigTest; |
| 260 | 260 | ||
| 261 | if (std.builtin.os.tag == .windows) { | ||
| 262 | _ = try std.os.windows.WSAStartup(2, 2); | ||
| 263 | } | ||
| 264 | defer { | ||
| 265 | if (std.builtin.os.tag == .windows) { | ||
| 266 | std.os.windows.WSACleanup() catch unreachable; | ||
| 267 | } | ||
| 268 | } | ||
| 269 | |||
| 261 | var server = net.StreamServer.init(.{}); | 270 | var server = net.StreamServer.init(.{}); |
| 262 | defer server.deinit(); | 271 | defer server.deinit(); |
| 263 | 272 |