9 int main(
int argc,
char* argv[])
19 const std::string
addr =
"inproc://testpeerlink";
25 auto uuids = subpeer.
waitfor(
"pub");
26 assert (uuids.size() == 1);
28 cerr <<
"pub uuid is " << uuids[0] << endl;
29 auto pubinfo = subpeer.peer_info(uuids[0]);
31 cerr <<
"pub nick is " << pubinfo.nick << endl;
32 assert (pubinfo.nick ==
"pub");
33 assert (pubinfo.headers.size() == 1);
34 auto feeds = pubinfo.branch(
"Feed");
36 cerr <<
"got " << feeds.size() <<
": " << feeds[
""] << endl;
37 assert(feeds.size() == 1);
39 std::string prefix =
"";
40 sub.setsockopt(ZMQ_SUBSCRIBE, prefix.c_str(), prefix.size());
42 sub.connect(feeds[
""]);
48 std::string hw =
"Hello World!";
50 pub.
send(zio::buffer(hw.data(), hw.size()));
52 cerr <<
"send "<<hw<<
"\n";
57 auto res = sub.recv(msg);
59 std::string hw2(static_cast<char*>(msg.
data()), msg.
size());
62 cerr <<
"recv "<<hw2<<
"\n";
const char * addr
inproc hangs. no messages ever get received by server. tcp/ipc okay.
int main(int argc, char *argv[])
size_t send(const void *buf_, size_t len_, int flags_=0)
void * data() ZMQ_NOTHROW
size_t size() const ZMQ_NOTHROW
void bind(std::string const &addr)
Peer at the network to discover peers and advertise self.
std::vector< uuid_t > waitfor(const nickname_t &nickname, timeout_t timeout=-1)
Wait for a peer of a given nickname to be discovered.