40 int rc =
zmq_bind (pub,
"inproc://soname");
55 char subscription[2] = { 1,
'A'};
64 assert(buffer[0] == 1);
65 assert(buffer[1] ==
'A');
80 assert(buffer[0] ==
'B');
96 assert (frontend && backend);
98 const char* topic =
"1";
99 const char* payload =
"X";
109 assert (
zmq_bind (xsub_proxy, frontend) == 0);
115 assert (
zmq_bind (xpub_proxy, backend) == 0);
133 assert (sub_buff [0] == 1);
134 assert (sub_buff [1] == *topic);
136 assert (
zmq_send (xsub_proxy, sub_buff, 2, 0) == 2);
149 assert (sub_buff [0] == 1);
150 assert (sub_buff [1] == *topic);
152 assert (
zmq_send (xsub_proxy, sub_buff, 2, 0) == 2);
159 assert (
zmq_send (pub, payload, 1, 0) == 1);
168 assert (topic_buff [0] == *topic);
170 assert (data_buff [0] == *payload);
172 assert (
zmq_send (xpub_proxy, data_buff, 1, 0) == 1);
179 assert (topic_buff [0] == *topic);
181 assert (data_buff [0] == *payload);
184 assert (topic_buff [0] == *topic);
186 assert (data_buff [0] == *payload);
196 assert (
zmq_recv (xpub_proxy, sub_buff, 2, 0) == 2);
197 assert (sub_buff [0] == 0);
198 assert (sub_buff [1] == *topic);
200 assert (
zmq_send (xsub_proxy, sub_buff, 2, 0) == 2);
203 assert (
zmq_recv (xpub_proxy, sub_buff, 2, 0) == 2
204 &&
"Should receive the second unsubscribe message.");
205 assert (sub_buff [0] == 0);
206 assert (sub_buff [1] == *topic);
208 assert (
zmq_send (xsub_proxy, sub_buff, 2, 0) == 2);
215 assert (
zmq_send (pub, payload, 1, 0) == 1);
222 assert (errno == EAGAIN);
234 assert (frontend && backend);
236 const char* topic1 =
"1";
237 const char* topic2 =
"2";
238 const char* payload =
"X";
248 assert (
zmq_bind (xsub_proxy, frontend) == 0);
254 assert (
zmq_bind (xpub_proxy, backend) == 0);
282 assert (buffer [0] == 1);
283 assert (buffer [1] == *topic1);
285 assert (
zmq_send (xsub_proxy, buffer, 2, 0) == 2);
288 assert (buffer [0] == 1);
289 assert (buffer [1] == *topic2);
291 assert (
zmq_send (xsub_proxy, buffer, 2, 0) == 2);
298 assert (
zmq_send (pub, payload, 1, 0) == 1);
300 assert (
zmq_send (pub, payload, 1, 0) == 1);
309 assert (topic_buff [0] == *topic1);
311 assert (data_buff [0] == *payload);
313 assert (
zmq_send (xpub_proxy, data_buff, 1, 0) == 1);
316 assert (topic_buff [0] == *topic2);
318 assert (data_buff [0] == *payload);
320 assert (
zmq_send (xpub_proxy, data_buff, 1, 0) == 1);
327 assert (topic_buff [0] == *topic2);
329 assert (data_buff [0] == *payload);
332 assert (topic_buff [0] == *topic1);
334 assert (data_buff [0] == *payload);
353 const char *frontend;
356 #if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS 357 frontend =
"ipc://frontend";
358 backend =
"ipc://backend";
362 frontend =
"tcp://127.0.0.1:5560";
363 backend =
"tcp://127.0.0.1:5561";
void msleep(int milliseconds)
ZMQ_EXPORT int zmq_setsockopt(void *s, int option, const void *optval, size_t optvallen)
ZMQ_EXPORT void * zmq_ctx_new(void)
void setup_test_environment(void)
ZMQ_EXPORT int zmq_recv(void *s, void *buf, size_t len, int flags)
ZMQ_EXPORT int zmq_send_const(void *s, const void *buf, size_t len, int flags)
ZMQ_EXPORT void * zmq_socket(void *, int type)
ZMQ_EXPORT int zmq_connect(void *s, const char *addr)
int test_missing_subscriptions(const char *frontend, const char *backend)
ZMQ_EXPORT int zmq_close(void *s)
ZMQ_EXPORT int zmq_send(void *s, const void *buf, size_t len, int flags)
int test_xpub_proxy_unsubscribe_on_disconnect(const char *frontend, const char *backend)
ZMQ_EXPORT int zmq_bind(void *s, const char *addr)
ZMQ_EXPORT int zmq_ctx_term(void *context)