aboutsummaryrefslogtreecommitdiff
path: root/tests/tcp.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-08 21:19:09 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-09 02:38:55 -0700
commitd64f12553eb6ceb67ed6f6a5b2ceb6c061d375ba (patch)
treef6bdac79578176f0d00528d191f862009e761eac /tests/tcp.c
parent5f0398de8edd1ed4ddbf6455c66273a6608aad9a (diff)
downloadnng-d64f12553eb6ceb67ed6f6a5b2ceb6c061d375ba.tar.gz
nng-d64f12553eb6ceb67ed6f6a5b2ceb6c061d375ba.tar.bz2
nng-d64f12553eb6ceb67ed6f6a5b2ceb6c061d375ba.zip
fixes #44 open protocol by "name" (symbol) instead number
fixes #38 Make protocols "pluggable", or at least optional This is a breaking change, as we've done away with the central registered list of protocols, and instead demand the user call nng_xxx_open() where xxx is a protocol name. (We did keep a table around in the compat framework though.) There is a nice way for protocols to plug in via an nni_proto_open(), where they can use a generic constructor that they use to build a protocol specific constructor (passing their ops vector in.)
Diffstat (limited to 'tests/tcp.c')
-rw-r--r--tests/tcp.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/tests/tcp.c b/tests/tcp.c
index b37e239c..3910cb7f 100644
--- a/tests/tcp.c
+++ b/tests/tcp.c
@@ -10,36 +10,34 @@
#include "convey.h"
#include "trantest.h"
-
// Inproc tests.
TestMain("TCP Transport", {
trantest_test_all("tcp://127.0.0.1:4450");
-
Convey("We cannot connect to wild cards", {
nng_socket s;
- So(nng_open(&s, NNG_PROTO_PAIR) == 0);
- Reset({
- nng_close(s);
- })
- So(nng_dial(s, "tcp://*:5555", NULL, NNG_FLAG_SYNCH) == NNG_EADDRINVAL);
- })
+ So(nng_pair_open(&s) == 0);
+ Reset({ nng_close(s); });
+ So(nng_dial(s, "tcp://*:5555", NULL, NNG_FLAG_SYNCH) ==
+ NNG_EADDRINVAL);
+ });
Convey("We can bind to wild card", {
nng_socket s1;
nng_socket s2;
- So(nng_open(&s1, NNG_PROTO_PAIR) == 0);
- So(nng_open(&s2, NNG_PROTO_PAIR) == 0);
+ So(nng_pair_open(&s1) == 0);
+ So(nng_pair_open(&s2) == 0);
Reset({
nng_close(s2);
nng_close(s1);
- })
+ });
So(nng_listen(s1, "tcp://*:5771", NULL, NNG_FLAG_SYNCH) == 0);
- So(nng_dial(s2, "tcp://127.0.0.1:5771", NULL, NNG_FLAG_SYNCH) == 0);
- })
+ So(nng_dial(
+ s2, "tcp://127.0.0.1:5771", NULL, NNG_FLAG_SYNCH) == 0);
+ });
nng_fini();
})