authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-11-22 10:29:45+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-01-11 21:43:15+01:00
log34720da3d0a4a98383639cbedcbe1aa885217ed6
tree183937da172d8cacda17a88df9a479bf4f2403ee
parentd0beb4badb9064893133c996b05c0748317adf24

Apparently unix sockets are supported on Windows

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;
12const fs = std.fs;12const fs = std.fs;
13const io = std.io;13const io = std.io;
1414
15pub 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.
17pub 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);
1620
17pub const Address = extern union {21pub 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;
260260
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();
263272