16 const char*
addr =
"ipc://test_tcs.ipc";
24 std::map<uint32_t,uint32_t> rids;
25 std::map<uint32_t, std::vector<int> > tosend;
27 zio::poller_t<> poller;
28 poller.add(s, zio::event_flags::pollin);
30 const auto wait = std::chrono::milliseconds{2000};
32 int64_t ttot=0, tmin=0, tmax=0;
40 std::vector<zio::poller_event<>> events(1);
42 int rc = poller.wait_all(events, wait);
52 const microseconds_type dtus = std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0);
53 const int64_t dt = dtus.count();
59 tmin = std::min(tmin, dt);
60 tmax = std::max(tmax, dt);
64 zio::info(
"server: #{} [{}, {}] <{}> tot={} dt={} [us]", count,
65 tmin, tmax, (ttot/count), ttot, dt);
69 auto res = s.recv(msg);
71 uint32_t rid = msg.routing_id();
74 if (msg.
size() == 0) {
82 int them = *
static_cast<int*
>(msg.
data());
88 tosend[rid].push_back(them);
91 if (rids.size() == 1) {
92 uint32_t orid = rids.begin()->first;
94 tosend[rid].push_back(them);
101 tosend[rid].push_back(them);
103 for (
const auto& rid_v : tosend) {
104 uint32_t rid = rid_v.first;
105 for (
auto them : rid_v.second) {
106 uint32_t orid = rids[rid];
108 msg.set_routing_id(orid);
109 auto ses = s.
send(msg, zio::send_flags::none);
122 zio::poller_t<> poller;
123 poller.add(c, zio::event_flags::pollin);
124 const auto wait = std::chrono::milliseconds{2000};
127 zio::info(
"client {}: sleeps for {}", me, zzz);
129 for (
int count=0; count<2000; ++count) {
132 c.
send(msg, zio::send_flags::none);
135 std::vector<zio::poller_event<>> events(1);
137 int rc = poller.wait_all(events, wait);
148 auto res = c.recv(msg);
150 int them = *
static_cast<int*
>(msg.
data());
165 std::thread ser(
server, std::ref(s));
166 zio::info(
"sleeping between server and client thread starts");
178 std::thread cli1(
client, std::ref(c1), 1);
179 std::thread cli2(
client, std::ref(c2), 2);
virtual const char * what() const ZMQ_NOTHROW ZMQ_OVERRIDE
const char * addr
inproc hangs. no messages ever get received by server. tcp/ipc okay.
size_t send(const void *buf_, size_t len_, int flags_=0)
void * data() ZMQ_NOTHROW
std::chrono::duration< int64_t, std::micro > microseconds_type
void client(std::string str)
void connect(std::string const &addr)
size_t size() const ZMQ_NOTHROW
void bind(std::string const &addr)