Networking Reference
In-Depth Information
printf("Received: %s\n", msg);
zstr_send(socket, "world");
free(msg);
}
zsocket_destroy(context, socket);
zctx_destroy(&context);
return 0;
}
Did you notice something different? Yes, we included the czmq.h header.
The code has completely changed.
Introduction to CZMQ
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
zctx
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 and zmq_
recv() and returning when SIGINT ( Ctrl + C ) or SIGTERM ( kill ) is called.
• It automatically closes the opened sockets before terminating the context.
Sample usage:
zctx_t* context = zctx_new();
 
Search MirCeyron ::




Custom Search