aboutsummaryrefslogtreecommitdiff
path: root/tests/tcp.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-09 16:13:24 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-09 16:13:24 -0700
commit032c74653cc2035b539ee48183055a9354e9b888 (patch)
tree0bbd532f8f91e796c80a63a89891132924d3651b /tests/tcp.c
parente469d1084d144961a72c4db1fb84cbd29ed4df8a (diff)
downloadnng-032c74653cc2035b539ee48183055a9354e9b888.tar.gz
nng-032c74653cc2035b539ee48183055a9354e9b888.tar.bz2
nng-032c74653cc2035b539ee48183055a9354e9b888.zip
fixes #48 tcp sometimes fails to get a port
Diffstat (limited to 'tests/tcp.c')
-rw-r--r--tests/tcp.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/tcp.c b/tests/tcp.c
index 3910cb7f..58c9bca7 100644
--- a/tests/tcp.c
+++ b/tests/tcp.c
@@ -1,5 +1,6 @@
//
// Copyright 2017 Garrett D'Amore <garrett@damore.org>
+// Copyright 2017 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -14,29 +15,34 @@
TestMain("TCP Transport", {
- trantest_test_all("tcp://127.0.0.1:4450");
+ trantest_test_all("tcp://127.0.0.1:%u");
Convey("We cannot connect to wild cards", {
nng_socket s;
+ char addr[NNG_MAXADDRLEN];
So(nng_pair_open(&s) == 0);
Reset({ nng_close(s); });
- So(nng_dial(s, "tcp://*:5555", NULL, NNG_FLAG_SYNCH) ==
- NNG_EADDRINVAL);
+ trantest_next_address(addr, "tcp://*:%u");
+ So(nng_dial(s, addr, NULL, NNG_FLAG_SYNCH) == NNG_EADDRINVAL);
});
Convey("We can bind to wild card", {
nng_socket s1;
nng_socket s2;
+ char addr[NNG_MAXADDRLEN];
+
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);
+ trantest_next_address(addr, "tcp://*:%u");
+ So(nng_listen(s1, addr, NULL, NNG_FLAG_SYNCH) == 0);
+ // reset port back one
+ trantest_prev_address(addr, "tcp://127.0.0.1:%u");
+ So(nng_dial(s2, addr, NULL, NNG_FLAG_SYNCH) == 0);
});
nng_fini();