summaryrefslogtreecommitdiff
path: root/tests/testutil.hpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-03-24 11:53:55 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-03-24 11:53:55 +0100
commitfb27a000d9383b503761d0124e7bd41115d70c9a (patch)
treee330e2f828cd0f62843d0f75892aff56289effda /tests/testutil.hpp
parentd4e83d26014f41eaa1698b4062de88fe7f36a669 (diff)
send/recv was changed to send/recv/sendmsg/recvmsg
send/recv now complies with POSIX by using raw buffers instead of message objects and by returning number of bytes sent/recvd instead of 0/-1. The return value is changed accordingly for sendmsg and recvmsg. Note that related man pages will be fixed in a separate patch. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'tests/testutil.hpp')
-rw-r--r--tests/testutil.hpp38
1 files changed, 11 insertions, 27 deletions
diff --git a/tests/testutil.hpp b/tests/testutil.hpp
index 6879dff..1fbf1f3 100644
--- a/tests/testutil.hpp
+++ b/tests/testutil.hpp
@@ -31,39 +31,23 @@ inline void bounce (void *sb, void *sc)
const char *content = "12345678ABCDEFGH12345678abcdefgh";
// Send the message.
- zmq_msg_t msg1;
- int rc = zmq_msg_init_size (&msg1, 32);
- memcpy (zmq_msg_data (&msg1), content, 32);
- rc = zmq_send (sc, &msg1, 0);
- assert (rc == 0);
- rc = zmq_msg_close (&msg1);
- assert (rc == 0);
+ int rc = zmq_send (sc, content, 32, 0);
+ assert (rc == 32);
// Bounce the message back.
- zmq_msg_t msg2;
- rc = zmq_msg_init (&msg2);
- assert (rc == 0);
- rc = zmq_recv (sb, &msg2, 0);
- assert (rc == 0);
- rc = zmq_send (sb, &msg2, 0);
- assert (rc == 0);
- rc = zmq_msg_close (&msg2);
- assert (rc == 0);
+ char buf1 [32];
+ rc = zmq_recv (sb, buf1, 32, 0);
+ assert (rc == 32);
+ rc = zmq_send (sb, buf1, 32, 0);
+ assert (rc == 32);
// Receive the bounced message.
- zmq_msg_t msg3;
- rc = zmq_msg_init (&msg3);
- assert (rc == 0);
- rc = zmq_recv (sc, &msg3, 0);
- assert (rc == 0);
+ char buf2 [32];
+ rc = zmq_recv (sc, buf2, 32, 0);
+ assert (rc == 32);
// Check whether the message is still the same.
- assert (zmq_msg_size (&msg3) == 32);
- assert (memcmp (zmq_msg_data (&msg3), content, 32) == 0);
-
- rc = zmq_msg_close (&msg3);
- assert (rc == 0);
+ assert (memcmp (buf2, content, 32) == 0);
}
-
#endif