Guest User

zmq pusher

a guest
May 7th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. //  Hello World client
  2. #include <zmq.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <unistd.h>
  6. #include <stdlib.h>
  7.  
  8. int main (int argc, char *argv[])
  9. {
  10.     void *context = zmq_ctx_new ();
  11.     void *pusher = zmq_socket (context, ZMQ_PUSH);
  12.     int opti = 20000000;
  13.  
  14.     zmq_setsockopt (pusher, ZMQ_SNDHWM, &opti, sizeof(opti));
  15.     zmq_connect (pusher, argc > 1 ? argv[1] : "tcp://192.168.1.1:13006");
  16.  
  17.     if (1) {
  18.     unsigned count = 0;
  19.     char buf[4] = { 't', 'e', 's', 't' };
  20.  
  21.     while (1) {
  22.         int rc = zmq_send (pusher, buf, sizeof(buf), ZMQ_DONTWAIT);
  23.         if (rc < 0) { printf("count: %u\n", count); exit(1); }
  24.         count++;
  25.     }
  26.     }
  27.  
  28.     zmq_close (pusher);
  29.     zmq_ctx_destroy (context);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment