From d64f12553eb6ceb67ed6f6a5b2ceb6c061d375ba Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 8 Aug 2017 21:19:09 -0700 Subject: 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.) --- tests/tcp.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'tests/tcp.c') 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(); }) -- cgit v1.2.3-70-g09d2