Guest User

zmqclient

a guest
Oct 15th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1.  
  2. #include <zmq.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <unistd.h>
  6.  
  7. int main (void)
  8. {
  9.     printf ("Connecting to hello world server…\n");
  10.     void *context = zmq_ctx_new ();
  11.     void *requester = zmq_socket (context, ZMQ_REQ);
  12.     zmq_connect (requester, "tcp://localhost:5555");
  13.  
  14.     int request_nbr;
  15.     for (request_nbr = 0; request_nbr != 10; request_nbr++) {
  16.         char buffer [10];
  17.         printf ("Sending Hello %d…\n", request_nbr);
  18.         zmq_send (requester, "Hello", 5, 0);
  19.         zmq_recv (requester, buffer, 10, 0);
  20.         printf ("Received World %d\n", request_nbr);
  21.     }
  22.     zmq_close (requester);
  23.     zmq_ctx_destroy (context);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment