Commit 873abdd2 authored by Martin Hurton's avatar Martin Hurton

Rename XREP/XREQ to ROUTER/DEALER in tests

parent 016df8e8
......@@ -27,19 +27,19 @@ int main (int argc, char *argv [])
{
fprintf (stderr, "test_invalid_rep running...\n");
// Create REQ/XREP wiring.
// Create REQ/ROUTER wiring.
void *ctx = zmq_init (1);
assert (ctx);
void *xrep_socket = zmq_socket (ctx, ZMQ_XREP);
assert (xrep_socket);
void *router_socket = zmq_socket (ctx, ZMQ_ROUTER);
assert (router_socket);
void *req_socket = zmq_socket (ctx, ZMQ_REQ);
assert (req_socket);
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);
rc = zmq_setsockopt (req_socket, ZMQ_LINGER, &linger, sizeof (int));
assert (rc == 0);
rc = zmq_bind (xrep_socket, "inproc://hi");
rc = zmq_bind (router_socket, "inproc://hi");
assert (rc == 0);
rc = zmq_connect (req_socket, "inproc://hi");
assert (rc == 0);
......@@ -53,23 +53,23 @@ int main (int argc, char *argv [])
int addr_size;
char bottom [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);
rc = zmq_recv (xrep_socket, bottom, sizeof (bottom), 0);
rc = zmq_recv (router_socket, bottom, sizeof (bottom), 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);
// 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);
// 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);
rc = zmq_send (xrep_socket, bottom, 0, ZMQ_SNDMORE);
rc = zmq_send (router_socket, bottom, 0, ZMQ_SNDMORE);
assert (rc == 0);
rc = zmq_send (xrep_socket, "b", 1, 0);
rc = zmq_send (router_socket, "b", 1, 0);
assert (rc == 1);
// Check whether we've got the valid reply.
......@@ -78,7 +78,7 @@ int main (int argc, char *argv [])
assert (body [0] == 'b');
// Tear down the wiring.
rc = zmq_close (xrep_socket);
rc = zmq_close (router_socket);
assert (rc == 0);
rc = zmq_close (req_socket);
assert (rc == 0);
......
......@@ -41,7 +41,7 @@ int main (int argc, char *argv [])
void *ctx = zmq_init (1);
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_XREP);
void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb);
do_bind_and_verify (sb, "tcp://127.0.0.1:5560");
......
......@@ -29,11 +29,11 @@ int main (int argc, char *argv [])
// Create the infrastructure
void *ctx = zmq_init (0);
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_XREP);
void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb);
int rc = zmq_bind (sb, "inproc://a");
assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_XREQ);
void *sc = zmq_socket (ctx, ZMQ_DEALER);
assert (sc);
rc = zmq_connect (sc, "inproc://a");
assert (rc == 0);
......
......@@ -33,13 +33,13 @@ int main (int argc, char *argv [])
assert (ctx);
// Create a req/rep device.
void *xreq = zmq_socket (ctx, ZMQ_XREQ);
assert (xreq);
int rc = zmq_bind (xreq, "tcp://127.0.0.1:5560");
void *dealer = zmq_socket (ctx, ZMQ_DEALER);
assert (dealer);
int rc = zmq_bind (dealer, "tcp://127.0.0.1:5560");
assert (rc == 0);
void *xrep = zmq_socket (ctx, ZMQ_XREP);
assert (xrep);
rc = zmq_bind (xrep, "tcp://127.0.0.1:5561");
void *router = zmq_socket (ctx, ZMQ_ROUTER);
assert (router);
rc = zmq_bind (router, "tcp://127.0.0.1:5561");
assert (rc == 0);
// Create a worker.
......@@ -65,13 +65,13 @@ int main (int argc, char *argv [])
zmq_msg_t msg;
rc = zmq_msg_init (&msg);
assert (rc == 0);
rc = zmq_recvmsg (xrep, &msg, 0);
rc = zmq_recvmsg (router, &msg, 0);
assert (rc >= 0);
int 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);
rc = zmq_sendmsg (xreq, &msg, rcvmore ? ZMQ_SNDMORE : 0);
rc = zmq_sendmsg (dealer, &msg, rcvmore ? ZMQ_SNDMORE : 0);
assert (rc >= 0);
}
......@@ -103,12 +103,12 @@ int main (int argc, char *argv [])
zmq_msg_t msg;
rc = zmq_msg_init (&msg);
assert (rc == 0);
rc = zmq_recvmsg (xreq, &msg, 0);
rc = zmq_recvmsg (dealer, &msg, 0);
assert (rc >= 0);
int rcvmore;
rc = zmq_getsockopt (xreq, ZMQ_RCVMORE, &rcvmore, &sz);
rc = zmq_getsockopt (dealer, ZMQ_RCVMORE, &rcvmore, &sz);
assert (rc == 0);
rc = zmq_sendmsg (xrep, &msg, rcvmore ? ZMQ_SNDMORE : 0);
rc = zmq_sendmsg (router, &msg, rcvmore ? ZMQ_SNDMORE : 0);
assert (rc >= 0);
}
......@@ -131,9 +131,9 @@ int main (int argc, char *argv [])
assert (rc == 0);
rc = zmq_close (rep);
assert (rc == 0);
rc = zmq_close (xrep);
rc = zmq_close (router);
assert (rc == 0);
rc = zmq_close (xreq);
rc = zmq_close (dealer);
assert (rc == 0);
rc = zmq_term (ctx);
assert (rc == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment