Very new to zig. I’m getting these long inlay hints for an error set. In this case, shouldn’t it be displaying just std.posix.AcceptError
?
My code:
const std = @import("std");
const net = std.net;
const posix = std.posix;
pub fn main() void {
const addr = try net.Address.parseIp("127.0.0.1", 8080);
const listener = try posix.socket(addr.any.family, posix.SOCK_STREAM, posix.IPPROTO.TCP);
defer posix.close(listener);
try posix.setsockopt(listener, posix.SOL_SOCKET, posix.SO_REUSEADDR, &std.mem.toBytes(c_int, 1));
try posix.bind(listener, addr.any);
try posix.listen(listener, 128);
while (true) {
var client_addr: net.Address = undefined;
var clien_adrr_len: posix.socklen_t = @sizeOf(net.Address);
const socket = posix.accept(listener, &client_addr.any, &clien_adrr_len, 0) catch |err| {
std.debug.print("Error accepting connection: {}\n", .{err});
continue;
};
socket.close();
}
}
Inlay hints: