zig icon indicating copy to clipboard operation
zig copied to clipboard

Trying to call std.net.Address.resolveIp fails on windows with a compiler error

Open rupakhetibinit opened this issue 1 year ago • 2 comments

Zig Version

0.14.0-dev.185+c40708a2c

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() !void {
    const stdout = std.io.getStdOut().writer();
    const address = try std.net.Address.resolveIp("127.0.0.1", 4221);
    var listener = try address.listen(.{
        .reuse_address = false,
    });
    try stdout.print("Started http server on port 4221", .{});

    defer listener.deinit();
}

The exact error I run into is this.

❯ zig build run
run
└─ run http-server
   └─ install
      └─ install http-server
         └─ zig build-exe http-server Debug native 1 errors
C:\Users\BINIT\scoop\persist\zigup\zig\0.14.0-dev.185+c40708a2c\files\lib\std\net.zig:756:5: error: std.net.if_nametoindex unimplemented for this OS
    @compileError("std.net.if_nametoindex unimplemented for this OS");
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    resolve: C:\Users\BINIT\scoop\persist\zigup\zig\0.14.0-dev.185+c40708a2c\files\lib\std\net.zig:614:46
    resolveIp6: C:\Users\BINIT\scoop\persist\zigup\zig\0.14.0-dev.185+c40708a2c\files\lib\std\net.zig:103:48
    4 reference(s) hidden; use '-freference-trace=6' to see all references

For some reason it's still calling resolveip6 even after calling and supposedly returning ip4 at least that's what I could figure out which seems like it shouldn't be happening because ipv4 should be already resolved before it reaches resolveip6 https://github.com/ziglang/zig/blob/c40708a2ce4f6ed1adcc1de39fc7b4fc27db32f8/lib/std/net.zig#L66-L87

Expected Behavior

Not get compiler error.

rupakhetibinit avatar Jul 07 '24 16:07 rupakhetibinit

I am also seeing this issue

vhorvath2010 avatar Sep 17 '24 04:09 vhorvath2010

I'm also getting this issue, not sure why its resolving ipv6

Wolfleader101 avatar Oct 13 '24 04:10 Wolfleader101