Skip to content

Instantly share code, notes, and snippets.

@jrfondren
Last active November 12, 2018 10:40
Show Gist options
  • Save jrfondren/b049085f8c74482b96097f7db16a18eb to your computer and use it in GitHub Desktop.
Save jrfondren/b049085f8c74482b96097f7db16a18eb to your computer and use it in GitHub Desktop.
trivial DNS
// zig build-exe dns1.zig --library c
const c = @cImport({
@cInclude("netdb.h");
@cInclude("stdio.h");
});
pub fn main() void {
if (c.gethostbyname(c"irc.freenode.net")) |host| {
if (host[0].h_addr_list) |res| {
if (res[0]) |first| {
_ = c.printf(c"%d.%d.%d.%d\n", first[0], first[1], first[2], first[3]);
}
}
}
}
@TBD
Copy link

TBD commented Nov 12, 2018

... thanks for the DNS Zig sample code. and for getr 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment