authorgravatar for ansg191@anshulg.comAnshul Gupta <ansg191@anshulg.com> 2026-06-01 16:48:12-07:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-09 15:49:05+02:00
logcb7c6e391872d2922a688c77def805883b69eba8
tree4d61dd352022fb612156d5771060fa5c25a15b2f
parentb2c230df5033864a19eb65defceac1cc3013be3c

std.Io.Threaded: respect options.family in netLookup

Previously `AF_UNSPEC` was passed unconditionally to `getaddrinfo`. This specifies `AF_INET` or `AF_INET6` depending on the value of HostName.LookupOptions.family. `AF_UNSPEC` is still set by default (when family == null).

1 files changed, 6 insertions(+), 1 deletions(-)

lib/std/Io/Threaded.zig+6-1
......@@ -13923,9 +13923,14 @@ fn netLookupFallible(
1392313923 var port_buffer: [8]u8 = undefined;
1392413924 const port_c = std.fmt.bufPrintSentinel(&port_buffer, "{d}", .{options.port}, 0) catch unreachable;
1392513925
13926 const family: i32 = if (options.family) |f| switch (f) {
13927 .ip4 => posix.AF.INET,
13928 .ip6 => posix.AF.INET6,
13929 } else posix.AF.UNSPEC;
13930
1392613931 const hints: posix.addrinfo = .{
1392713932 .flags = .{ .CANONNAME = options.canonical_name_buffer != null, .NUMERICSERV = true },
13928 .family = posix.AF.UNSPEC,
13933 .family = family,
1392913934 .socktype = posix.SOCK.STREAM,
1393013935 .protocol = posix.IPPROTO.TCP,
1393113936 .canonname = null,