Rename XREP/XREQ to ROUTER/DEALER in tests

This commit is contained in:
Martin Hurton 2012-04-25 01:03:38 +02:00
parent 016df8e89c
commit 873abdd24c
4 changed files with 30 additions and 30 deletions

View File

@ -27,19 +27,19 @@ int main (int argc, char *argv [])
{ {
fprintf (stderr, "test_invalid_rep running...\n"); fprintf (stderr, "test_invalid_rep running...\n");
// Create REQ/XREP wiring. // Create REQ/ROUTER wiring.
void *ctx = zmq_init (1); void *ctx = zmq_init (1);
assert (ctx); assert (ctx);
void *xrep_socket = zmq_socket (ctx, ZMQ_XREP); void *router_socket = zmq_socket (ctx, ZMQ_ROUTER);
assert (xrep_socket); assert (router_socket);
void *req_socket = zmq_socket (ctx, ZMQ_REQ); void *req_socket = zmq_socket (ctx, ZMQ_REQ);
assert (req_socket); assert (req_socket);
int linger = 0; int linger = 0;
int rc = zmq_setsockopt (xrep_socket, ZMQ_LINGER, &linger, sizeof (int)); int rc = zmq_setsockopt (router_socket, ZMQ_LINGER, &linger, sizeof (int));
assert (rc == 0); assert (rc == 0);
rc = zmq_setsockopt (req_socket, ZMQ_LINGER, &linger, sizeof (int)); rc = zmq_setsockopt (req_socket, ZMQ_LINGER, &linger, sizeof (int));
assert (rc == 0); assert (rc == 0);
rc = zmq_bind (xrep_socket, "inproc://hi"); rc = zmq_bind (router_socket, "inproc://hi");
assert (rc == 0); assert (rc == 0);
rc = zmq_connect (req_socket, "inproc://hi"); rc = zmq_connect (req_socket, "inproc://hi");
assert (rc == 0); assert (rc == 0);
@ -53,23 +53,23 @@ int main (int argc, char *argv [])
int addr_size; int addr_size;
char bottom [1]; char bottom [1];
char body [1]; char body [1];
addr_size = zmq_recv (xrep_socket, addr, sizeof (addr), 0); addr_size = zmq_recv (router_socket, addr, sizeof (addr), 0);
assert (addr_size >= 0); assert (addr_size >= 0);
rc = zmq_recv (xrep_socket, bottom, sizeof (bottom), 0); rc = zmq_recv (router_socket, bottom, sizeof (bottom), 0);
assert (rc == 0); assert (rc == 0);
rc = zmq_recv (xrep_socket, body, sizeof (body), 0); rc = zmq_recv (router_socket, body, sizeof (body), 0);
assert (rc == 1); assert (rc == 1);
// Send invalid reply. // Send invalid reply.
rc = zmq_send (xrep_socket, addr, addr_size, 0); rc = zmq_send (router_socket, addr, addr_size, 0);
assert (rc == addr_size); assert (rc == addr_size);
// Send valid reply. // Send valid reply.
rc = zmq_send (xrep_socket, addr, addr_size, ZMQ_SNDMORE); rc = zmq_send (router_socket, addr, addr_size, ZMQ_SNDMORE);
assert (rc == addr_size); assert (rc == addr_size);
rc = zmq_send (xrep_socket, bottom, 0, ZMQ_SNDMORE); rc = zmq_send (router_socket, bottom, 0, ZMQ_SNDMORE);
assert (rc == 0); assert (rc == 0);
rc = zmq_send (xrep_socket, "b", 1, 0); rc = zmq_send (router_socket, "b", 1, 0);
assert (rc == 1); assert (rc == 1);
// Check whether we've got the valid reply. // Check whether we've got the valid reply.
@ -78,7 +78,7 @@ int main (int argc, char *argv [])
assert (body [0] == 'b'); assert (body [0] == 'b');
// Tear down the wiring. // Tear down the wiring.
rc = zmq_close (xrep_socket); rc = zmq_close (router_socket);
assert (rc == 0); assert (rc == 0);
rc = zmq_close (req_socket); rc = zmq_close (req_socket);
assert (rc == 0); assert (rc == 0);

View File

@ -41,7 +41,7 @@ int main (int argc, char *argv [])
void *ctx = zmq_init (1); void *ctx = zmq_init (1);
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_XREP); void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb); assert (sb);
do_bind_and_verify (sb, "tcp://127.0.0.1:5560"); do_bind_and_verify (sb, "tcp://127.0.0.1:5560");

View File

@ -29,11 +29,11 @@ int main (int argc, char *argv [])
// Create the infrastructure // Create the infrastructure
void *ctx = zmq_init (0); void *ctx = zmq_init (0);
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_XREP); void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb); assert (sb);
int rc = zmq_bind (sb, "inproc://a"); int rc = zmq_bind (sb, "inproc://a");
assert (rc == 0); assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_XREQ); void *sc = zmq_socket (ctx, ZMQ_DEALER);
assert (sc); assert (sc);
rc = zmq_connect (sc, "inproc://a"); rc = zmq_connect (sc, "inproc://a");
assert (rc == 0); assert (rc == 0);

View File

@ -33,13 +33,13 @@ int main (int argc, char *argv [])
assert (ctx); assert (ctx);
// Create a req/rep device. // Create a req/rep device.
void *xreq = zmq_socket (ctx, ZMQ_XREQ); void *dealer = zmq_socket (ctx, ZMQ_DEALER);
assert (xreq); assert (dealer);
int rc = zmq_bind (xreq, "tcp://127.0.0.1:5560"); int rc = zmq_bind (dealer, "tcp://127.0.0.1:5560");
assert (rc == 0); assert (rc == 0);
void *xrep = zmq_socket (ctx, ZMQ_XREP); void *router = zmq_socket (ctx, ZMQ_ROUTER);
assert (xrep); assert (router);
rc = zmq_bind (xrep, "tcp://127.0.0.1:5561"); rc = zmq_bind (router, "tcp://127.0.0.1:5561");
assert (rc == 0); assert (rc == 0);
// Create a worker. // Create a worker.
@ -65,13 +65,13 @@ int main (int argc, char *argv [])
zmq_msg_t msg; zmq_msg_t msg;
rc = zmq_msg_init (&msg); rc = zmq_msg_init (&msg);
assert (rc == 0); assert (rc == 0);
rc = zmq_recvmsg (xrep, &msg, 0); rc = zmq_recvmsg (router, &msg, 0);
assert (rc >= 0); assert (rc >= 0);
int rcvmore; int rcvmore;
size_t sz = sizeof (rcvmore); size_t sz = sizeof (rcvmore);
rc = zmq_getsockopt (xrep, ZMQ_RCVMORE, &rcvmore, &sz); rc = zmq_getsockopt (router, ZMQ_RCVMORE, &rcvmore, &sz);
assert (rc == 0); assert (rc == 0);
rc = zmq_sendmsg (xreq, &msg, rcvmore ? ZMQ_SNDMORE : 0); rc = zmq_sendmsg (dealer, &msg, rcvmore ? ZMQ_SNDMORE : 0);
assert (rc >= 0); assert (rc >= 0);
} }
@ -103,12 +103,12 @@ int main (int argc, char *argv [])
zmq_msg_t msg; zmq_msg_t msg;
rc = zmq_msg_init (&msg); rc = zmq_msg_init (&msg);
assert (rc == 0); assert (rc == 0);
rc = zmq_recvmsg (xreq, &msg, 0); rc = zmq_recvmsg (dealer, &msg, 0);
assert (rc >= 0); assert (rc >= 0);
int rcvmore; int rcvmore;
rc = zmq_getsockopt (xreq, ZMQ_RCVMORE, &rcvmore, &sz); rc = zmq_getsockopt (dealer, ZMQ_RCVMORE, &rcvmore, &sz);
assert (rc == 0); assert (rc == 0);
rc = zmq_sendmsg (xrep, &msg, rcvmore ? ZMQ_SNDMORE : 0); rc = zmq_sendmsg (router, &msg, rcvmore ? ZMQ_SNDMORE : 0);
assert (rc >= 0); assert (rc >= 0);
} }
@ -131,9 +131,9 @@ int main (int argc, char *argv [])
assert (rc == 0); assert (rc == 0);
rc = zmq_close (rep); rc = zmq_close (rep);
assert (rc == 0); assert (rc == 0);
rc = zmq_close (xrep); rc = zmq_close (router);
assert (rc == 0); assert (rc == 0);
rc = zmq_close (xreq); rc = zmq_close (dealer);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_term (ctx);
assert (rc == 0); assert (rc == 0);