CZMQ is a high-level C library for ZeroMQ. Its main purpose is to minimize the differences between ZeroMQ v2.x and v3.x and also to enable doing more with less code. If you recall from Chapter 1, Getting Started, we said that the examples are written for ZeroMQ v3.2. Therefore, they may not work with ZeroMQ v2.2 or older.
It includes list and hash structures and lets developers work with strings and multi-part messages easier. It also automatically closes opened sockets when a given context is terminated.
Linking CZMQ with your ZeroMQ application is simple:
gcc –lczmq –o program program.c
This is a wrapper for the ZeroMQ context. Its main features are as follows:
Setting up signal handling, thus blocking calls such as
zmq_poll
andzmq_recv()
and returning whenSIGINT
(Ctrl + C) orSIGTERM
(kill
) is called.It automatically closes the opened sockets before terminating the context.
Sample usage:
zctx_t* context = zctx_new();