- Tight Zig wrapper or bindings to libzmq, with some minimal helpers.
- For a more high-level API, see zzmq.
$ zig fetch --save 'git+https://github.com/notcancername/zlzmq#master'
const zlzmq_dep = b.dependency("zlzmq", .{});
exe.root_module.addImport("zlzmq", zlzmq_dep.module("zlzmq"));
To vendor and statically link libzmq, you can use notcancername/libzmq. See that for features and libraries you might want. Note that this is a security risk since it makes updates impossible without recompiling.
$ zig fetch --save 'git+https://github.com/notcancername/libzmq#master'
const libzmq_dep = b.dependency("libzmq", .{ .target = target, .optimize = .optimize, .shared = false });
const libzmq = libzmq_dep.artifact("libzmq");
exe.linkLibrary(libzmq);
Context
: used byzmq_ctx_*
functionsSocket
: used by all functions that operate on socketsMessage
:zmq_msg_t
z85
: functions that deal with Z85curve
: functions for dealing withZMQ_CURVE
authentication and encryption
const zmq = @import("zlzmq");
pub fn main() !void {
const ctx = try zmq.Context.init();
defer ctx.deinit();
const rep = try ctx.socket(.rep);
defer rep.close();
while (true) {
var buf: [128]u8 = undefined;
const len = try rep.recv(&buf, .{});
if (std.mem.eql(u8, buf[0..len], "quit")) break;
try rep.send(buf[0..len], .{});
}
}