SHARE
TWEET

ZeroMQ publisher problem

a guest Sep 21st, 2012 28 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2.  
  3. #include <iostream>
  4. #include <stdint.h>
  5. #include <autolink_zeromq.hpp>
  6.  
  7. #include "zmq.hpp"
  8.  
  9. using namespace std;
  10.  
  11. int _tmain(int argc, _TCHAR* argv[])
  12. {
  13.         const size_t buffer_size = 1 * 1024 * 1024;
  14.         const uint64_t high_water_mark = 4;
  15.  
  16.         try
  17.         {
  18.                 zmq::context_t c(4);
  19.                 zmq::socket_t sock(c, ZMQ_PUB);
  20.                 sock.bind("epgm://224.9.8.7:1234");
  21.                 sock.setsockopt(ZMQ_HWM, &high_water_mark, sizeof(high_water_mark));
  22.  
  23.                 // NEVER ENDING!
  24.                 while (true)
  25.                 {
  26.                         zmq::message_t* t = new zmq::message_t(buffer_size);
  27.                         memset(t->data(), '!', buffer_size);
  28.  
  29.                         if (!sock.send(*t))
  30.                         {
  31.                                 Sleep(1000);
  32.                         }
  33.  
  34.                         delete t;
  35.                 }
  36.  
  37.                 sock.close();
  38.         }
  39.         catch (zmq::error_t e)
  40.         {
  41.                 cerr << e.what();
  42.         }
  43.  
  44.         return 0;
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top