mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
Apparently unix sockets are supported on Windows
Starting from Windows 10 build 17063.
This commit is contained in:
parent
d0beb4badb
commit
34720da3d0
@ -12,7 +12,11 @@ const os = std.os;
|
||||
const fs = std.fs;
|
||||
const io = std.io;
|
||||
|
||||
pub const has_unix_sockets = @hasDecl(os, "sockaddr_un");
|
||||
// Windows 10 added support for unix sockets in build 17063, redstone 4 is the
|
||||
// first release to support them.
|
||||
pub const has_unix_sockets = @hasDecl(os, "sockaddr_un") and
|
||||
(builtin.os.tag != .windows or
|
||||
std.Target.current.os.version_range.windows.isAtLeast(.win10_rs4) orelse false);
|
||||
|
||||
pub const Address = extern union {
|
||||
any: os.sockaddr,
|
||||
|
||||
@ -258,6 +258,15 @@ test "listen on a unix socket, send bytes, receive bytes" {
|
||||
if (builtin.single_threaded) return error.SkipZigTest;
|
||||
if (!net.has_unix_sockets) return error.SkipZigTest;
|
||||
|
||||
if (std.builtin.os.tag == .windows) {
|
||||
_ = try std.os.windows.WSAStartup(2, 2);
|
||||
}
|
||||
defer {
|
||||
if (std.builtin.os.tag == .windows) {
|
||||
std.os.windows.WSACleanup() catch unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
var server = net.StreamServer.init(.{});
|
||||
defer server.deinit();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user