mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-17 16:43:58 +00:00
commit
400cbc208a
@ -61,12 +61,12 @@ int main (void)
|
|||||||
assert(from);
|
assert(from);
|
||||||
|
|
||||||
val = 0;
|
val = 0;
|
||||||
zmq_setsockopt (from, ZMQ_LINGER, &val, sizeof(val));
|
zmq_setsockopt (from, ZMQ_LINGER, &val, sizeof (val));
|
||||||
// This pipe will not connect
|
// This pipe will not connect
|
||||||
rc = zmq_connect (from, "tcp://localhost:5556");
|
rc = zmq_connect (from, "tcp://localhost:5556");
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
// This pipe will
|
// This pipe will
|
||||||
rc = zmq_connect (from, "tcp://localhost:5555");
|
rc = zmq_connect (from, "tcp://localhost:6555");
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
// We send 10 messages, 5 should just get stuck in the queue
|
// We send 10 messages, 5 should just get stuck in the queue
|
||||||
@ -112,7 +112,6 @@ int main (void)
|
|||||||
// cause the pipe attachment to be delayed until the connection
|
// cause the pipe attachment to be delayed until the connection
|
||||||
// succeeds.
|
// succeeds.
|
||||||
context = zmq_ctx_new();
|
context = zmq_ctx_new();
|
||||||
fprintf (stderr, " Rerunning with DELAY_ATTACH_ON_CONNECT\n");
|
|
||||||
|
|
||||||
// Bind the valid socket
|
// Bind the valid socket
|
||||||
to = zmq_socket (context, ZMQ_PULL);
|
to = zmq_socket (context, ZMQ_PULL);
|
||||||
@ -182,7 +181,6 @@ int main (void)
|
|||||||
// block. Then we reconnect and verify messages flow again.
|
// block. Then we reconnect and verify messages flow again.
|
||||||
context = zmq_ctx_new();
|
context = zmq_ctx_new();
|
||||||
void *context2 = zmq_ctx_new();
|
void *context2 = zmq_ctx_new();
|
||||||
fprintf (stderr, " Running DELAY_ATTACH_ON_CONNECT with disconnect\n");
|
|
||||||
|
|
||||||
to = zmq_socket (context2, ZMQ_PULL);
|
to = zmq_socket (context2, ZMQ_PULL);
|
||||||
assert (to);
|
assert (to);
|
||||||
@ -257,4 +255,5 @@ int main (void)
|
|||||||
|
|
||||||
rc = zmq_ctx_destroy(context2);
|
rc = zmq_ctx_destroy(context2);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,16 +40,14 @@ int main(int argc, char** argv) {
|
|||||||
zmq_msg_t msg;
|
zmq_msg_t msg;
|
||||||
zmq_msg_init (&msg);
|
zmq_msg_init (&msg);
|
||||||
zmq_msg_recv (&msg, pubSocket, 0);
|
zmq_msg_recv (&msg, pubSocket, 0);
|
||||||
int msgSize = zmq_msg_size(&msg);
|
|
||||||
char* buffer = (char*)zmq_msg_data(&msg);
|
char* buffer = (char*)zmq_msg_data(&msg);
|
||||||
|
|
||||||
if (buffer[0] == 0) {
|
if (buffer[0] == 0) {
|
||||||
assert(isSubscribed);
|
assert(isSubscribed);
|
||||||
printf("unsubscribing from '%s'\n", strndup(buffer + 1, msgSize - 1));
|
|
||||||
isSubscribed = false;
|
isSubscribed = false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
assert(!isSubscribed);
|
assert(!isSubscribed);
|
||||||
printf("subscribing on '%s'\n", strndup(buffer + 1, msgSize - 1));
|
|
||||||
isSubscribed = true;
|
isSubscribed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,11 +64,6 @@ int main(int argc, char** argv) {
|
|||||||
zmq_msg_t msg;
|
zmq_msg_t msg;
|
||||||
zmq_msg_init (&msg);
|
zmq_msg_init (&msg);
|
||||||
zmq_msg_recv (&msg, subSocket, 0);
|
zmq_msg_recv (&msg, subSocket, 0);
|
||||||
int msgSize = zmq_msg_size(&msg);
|
|
||||||
char* buffer = (char*)zmq_msg_data(&msg);
|
|
||||||
|
|
||||||
printf("received on subscriber '%s'\n", strndup(buffer, msgSize));
|
|
||||||
|
|
||||||
zmq_getsockopt (subSocket, ZMQ_RCVMORE, &more, &more_size);
|
zmq_getsockopt (subSocket, ZMQ_RCVMORE, &more, &more_size);
|
||||||
zmq_msg_close (&msg);
|
zmq_msg_close (&msg);
|
||||||
|
|
||||||
|
@ -29,11 +29,10 @@ static void do_bind_and_verify (void *s, const char *endpoint)
|
|||||||
{
|
{
|
||||||
int rc = zmq_bind (s, endpoint);
|
int rc = zmq_bind (s, endpoint);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
char reported [255];
|
||||||
char test [255];
|
size_t size = 255;
|
||||||
size_t siz = 255;
|
rc = zmq_getsockopt (s, ZMQ_LAST_ENDPOINT, reported, &size);
|
||||||
rc = zmq_getsockopt (s, ZMQ_LAST_ENDPOINT, test, &siz);
|
assert (rc == 0 && strcmp (reported, endpoint) == 0);
|
||||||
assert (rc == 0 && strcmp (test, endpoint) == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user