Zig
Zig
DNS Lookup
Do a DNS lookup to resolve a hostname to an IP address.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const socket = try chilkat.Socket.init();
defer socket.deinit();
const max_wait_ms = 10000;
const ip_addr = socket.dnsLookup(alloc, "www.chilkatsoft.com", max_wait_ms) catch {
std.debug.print("{s}\n", .{try socket.getLastErrorText(alloc)});
return;
};
std.debug.print("IP Address: {s}\n", .{ip_addr});
}