Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Hello World client
- #include <zmq.h>
- #include <string.h>
- #include <stdio.h>
- #include <unistd.h>
- int main (int argc, char *argv[])
- {
- void *context = zmq_ctx_new ();
- void *puller = zmq_socket (context, ZMQ_PULL);
- int opti = 10000;
- zmq_setsockopt (puller, ZMQ_RCVHWM, &opti, sizeof(opti));
- zmq_bind (puller, argc > 1 ? argv[1] : "tcp://*:13006");
- if (1) {
- // initialize poll set
- zmq_pollitem_t items[] = { { puller, 0, ZMQ_POLLIN, 0 } };
- while (1) {
- zmq_poll(items, 1, -1);
- if (items[0].revents & ZMQ_POLLIN) {
- zmq_msg_t msg;
- zmq_msg_init(&msg);
- zmq_msg_recv(&msg, puller, 0);
- zmq_msg_close(&msg);
- }
- }
- }
- zmq_close (puller);
- zmq_ctx_destroy (context);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment