Created
February 1, 2011 10:53
-
-
Save ianbarber/805701 to your computer and use it in GitHub Desktop.
Dual Identity 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 <zmq.h> | |
#include <pthread.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#include <sys/time.h> | |
#include <time.h> | |
#include <unistd.h> | |
#include <assert.h> | |
int main () { | |
void *context = zmq_init (1); | |
// We send updates via this socket | |
void *publisher = zmq_socket (context, ZMQ_PUB); | |
zmq_bind (publisher, "tcp://*:5565"); | |
void *sub1 = zmq_socket (context, ZMQ_PUB); | |
zmq_setsockopt(sub1, ZMQ_IDENTITY, "test", sizeof("test")); | |
zmq_connect (sub1, "tcp://*:5565"); | |
void *sub2 = zmq_socket (context, ZMQ_PUB); | |
zmq_setsockopt(sub2, ZMQ_IDENTITY, "test", sizeof("test")); | |
zmq_connect (sub2, "tcp://*:5565"); | |
zmq_msg_t message; | |
zmq_msg_init_size (&message, sizeof("test")-1); | |
memcpy (zmq_msg_data (&message), "test", sizeof("test")-1); | |
zmq_send(publisher, &message, 0); | |
sleep(1); | |
zmq_close (publisher); | |
zmq_close (sub1); | |
zmq_close (sub2); | |
zmq_term (context); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment