Earlier quoted context omitted.
You can use any c libraries networking or socket implementations in zig but I think thats as far as it goes at the moment.
Can you though? I cant get cURL to work: https://github.com/ziglang/zig/issues/988
// curl-test.zig
// Direct hand-translation from curl's simple.c example
usingnamespace @cImport({
@cInclude("stdio.h");
@cInclude("curl/curl.h");
});
pub fn main() anyerror!void {
var curl = curl_easy_init();
var res: CURLcode = undefined;
if(curl != null) {
_ = curl_easy_setopt(curl, CURLoption.CURLOPT_URL,
c"https://example.com");
_ = curl_easy_setopt(curl, CURLoption.CURLOPT_FOLLOWLOCATION, c_long(1));
res = curl_easy_perform(curl);
if(res != CURLcode.CURLE_OK) {
_ = fprintf(stderr, c"curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
}
curl_easy_cleanup(curl);
}
}
Buildable with "zig build-exe curl-test.zig --library c --library curl" (I have to add "-isystem /usr/include --library-path /usr/lib64" to the end of that on Slackware64 14.2; YMMV). Should produce a runnable "curl-test" (or "curl-test.exe") binary executable in the current dir.