-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.os-windowsMicrosoft WindowsMicrosoft Windowsstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
const std = @import("std");
pub fn main() anyerror!void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
const list = try std.net.getAddressList(allocator, "ziglang.org", 443);
std.log.info("{}", .{list.addrs[0]});
}This program crashes with the error error.Unexpected: GetLastError(10093): Either the application has not called WSAStartup, or WSAStartup failed.. To get this to work you need to add a call to WSAStartup as follows:
const std = @import("std");
pub fn main() anyerror!void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
_ = try std.os.windows.WSAStartup(2, 2);
const list = try std.net.getAddressList(allocator, "google.com", 443);
std.log.info("{}", .{list.addrs[0]});
try std.os.windows.WSACleanup();
}The os.socket API abstracts this call away from user-code through the WSASocketW in os/windows.zig, which initializes WSA if needed. It seems right to me that the std.net APIs should do the same.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.os-windowsMicrosoft WindowsMicrosoft Windowsstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.