Created
December 19, 2011 11:20
-
-
Save danielnorberg/1496730 to your computer and use it in GitHub Desktop.
zeromq 3 pub assert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <zmq.h> | |
int main (int argc, const char * argv[]) | |
{ | |
void *ctx = zmq_init (1); | |
void *pub = zmq_socket (ctx, ZMQ_PUB); | |
zmq_bind (pub, "tcp://*:4711"); | |
void *sub = zmq_socket (ctx, ZMQ_XSUB); | |
zmq_connect (sub, "tcp://localhost:4711"); | |
sleep(1); | |
for (long i = 0;;i++) { | |
zmq_send(sub, "\1foobar", 7, 0); | |
zmq_send(sub, "\0foobar", 7, 0); | |
if (i % 1000 == 0) { | |
// trigger handling of subscriptions | |
zmq_send(pub, "baz", 3, 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment