Last active
November 12, 2018 10:40
-
-
Save jrfondren/b049085f8c74482b96097f7db16a18eb to your computer and use it in GitHub Desktop.
trivial DNS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
... thanks for the DNS Zig sample code. and for getr 😄