diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-04-04 12:37:34 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-04-04 13:13:24 -0700 |
| commit | 45f455064b5704f3d5ed8ecf9f197a18fe72ee59 (patch) | |
| tree | 76a626029f3a5a818b113b7e4342efaf6220a03f /tests/reqrep.c | |
| parent | 505a9bce029e51540739c853a6c9eef0ecfb2e90 (diff) | |
| download | nng-45f455064b5704f3d5ed8ecf9f197a18fe72ee59.tar.gz nng-45f455064b5704f3d5ed8ecf9f197a18fe72ee59.tar.bz2 nng-45f455064b5704f3d5ed8ecf9f197a18fe72ee59.zip | |
fixes #331 replace NNG_OPT_RAW option with constructor
This makes the raw mode something that is immutable, determined
at socket construction. This is an enabling change for the
separate context support coming soon.
As a result, this is an API breaking change for users of the raw
mode option (NNG_OPT_RAW). There aren't many of them out there.
Cooked mode is entirely unaffected.
There are changes to tests and documentation included.
Diffstat (limited to 'tests/reqrep.c')
| -rw-r--r-- | tests/reqrep.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/tests/reqrep.c b/tests/reqrep.c index 4e837c34..97ed371a 100644 --- a/tests/reqrep.c +++ b/tests/reqrep.c @@ -13,6 +13,7 @@ #include "protocol/reqrep0/rep.h" #include "protocol/reqrep0/req.h" #include "stubs.h" +#include "supplemental/util/platform.h" #include <string.h> @@ -135,19 +136,44 @@ TestMain("REQ/REP pattern", { So(nng_listen(rep, addr, NULL, 0) == 0); So(nng_dial(req, addr, NULL, 0) == 0); + // Send req #1 (abc). So(nng_sendmsg(req, abc, 0) == 0); + + // Sleep a bit. This is so that we ensure that our + // request gets to the far side. (If we cancel too + // fast, then our outgoing send will be canceled before + // it gets to the wire.) + nng_msleep(20); + + // Send the next next request ("def"). Note that + // the REP side server will have already buffered the receive + // request, and should simply be waiting for us to reply to + // abc. So(nng_sendmsg(req, def, 0) == 0); + + // Receive the first request (should be abc) on the REP server. So(nng_recvmsg(rep, &cmd, 0) == 0); - So(cmd != NULL); + So(nng_msg_len(cmd) == 4); + So(strcmp(nng_msg_body(cmd), "abc") == 0); + // REP sends the reply to first command. This will be + // discarded by the REQ server. So(nng_sendmsg(rep, cmd, 0) == 0); + + // Now get the next command from the REP; should be "def". So(nng_recvmsg(rep, &cmd, 0) == 0); + So(nng_msg_len(cmd) == 4); + So(strcmp(nng_msg_body(cmd), "def") == 0); + + // And send it back to REQ. So(nng_sendmsg(rep, cmd, 0) == 0); - So(nng_recvmsg(req, &cmd, 0) == 0); + // Try a req command. This should give back "def" + So(nng_recvmsg(req, &cmd, 0) == 0); So(nng_msg_len(cmd) == 4); - So(memcmp(nng_msg_body(cmd), "def", 4) == 0); + So(strcmp(nng_msg_body(cmd), "def") == 0); nng_msg_free(cmd); }); + nng_fini(); }) |
