Advertisement
Guest User

Untitled

a guest
May 9th, 2014
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.65 KB | None | 0 0
  1. Publisher:
  2.  
  3.     void *context = zmq_ctx_new ();
  4.     void *publisher = zmq_socket (context, ZMQ_PUB);
  5.     int rc = zmq_bind(publisher, "epgm://en0;224.0.0.250:5555");
  6.  
  7.     int rcvval  = 20000000;
  8.     int m = zmq_setsockopt(publisher, ZMQ_SNDBUF, &rcvval, sizeof rcvval);
  9.  
  10.     int optval = 100;
  11.     m =  zmq_setsockopt(publisher, ZMQ_RATE, &optval, sizeof(optval));
  12.  
  13.     optval = 1;
  14.     m =  zmq_setsockopt(publisher, ZMQ_RECOVERY_IVL, &optval, sizeof(optval));
  15.  
  16.     optval = 65000000;
  17.     m =  zmq_setsockopt(publisher, ZMQ_SNDHWM, &optval, sizeof(optval));
  18.  
  19.     optval = 0;
  20.     size_t opt_size = sizeof(optval);
  21.     m = zmq_getsockopt(publisher, ZMQ_SNDBUF, &optval, &opt_size);
  22.  
  23.     char test[1000000];
  24.     char* str = "aaaaabvbvbbvbvbvbvbvbvbvbbvbvbvbdvbhdvbdvhbdvhdbvhdbvhdbvhdbvdhvbdhvbdhvbdhvbdhvbdhvbdhvbdhhvbdhvbdh";
  25.     for(int i = 0; i < 5000; i++)
  26.     {
  27.         strcat(test, str);
  28.     }
  29.  
  30.     int sent_size = s_send(publisher, test);
  31.  
  32. Subscriber:
  33.  
  34.     void *context = zmq_ctx_new ();
  35.     void *subscriber = zmq_socket (context, ZMQ_SUB);
  36.     int rc = zmq_connect(subscriber, "epgm://en0;224.0.0.250:5555");
  37.     assert (rc == 0);
  38.  
  39.     rc = zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE,
  40.                      "", 0);
  41.     assert (rc == 0);
  42.  
  43.     int rcvval = 20000000;
  44.     int m = zmq_setsockopt(subscriber, ZMQ_RCVBUF, &rcvval, sizeof rcvval);
  45.  
  46.     int optval = 65000000;
  47.     m =  zmq_setsockopt(subscriber, ZMQ_RCVHWM, &optval, sizeof(optval));
  48.  
  49.     optval = 1;
  50.     m =  zmq_setsockopt(subscriber, ZMQ_RECOVERY_IVL, &optval, sizeof(optval));
  51.  
  52.     optval = 100;
  53.     m =  zmq_setsockopt(subscriber, ZMQ_RATE, &optval, sizeof(optval));
  54.    
  55.     char *bytesChar = s_recv(subscriber);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement