summaryrefslogtreecommitdiff
path: root/tests/tcp.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-03-04 17:04:11 -0800
committerGarrett D'Amore <garrett@damore.org>2018-03-04 19:42:17 -0800
commit23a38d766780f4749945d84316b4e0a71e707b15 (patch)
tree336cf1bfc7c7e32999653a4c4014232d2b735a3e /tests/tcp.c
parent0094f83a9e3b54d6cbfc1ea1885036366b87b991 (diff)
downloadnng-23a38d766780f4749945d84316b4e0a71e707b15.tar.gz
nng-23a38d766780f4749945d84316b4e0a71e707b15.tar.bz2
nng-23a38d766780f4749945d84316b4e0a71e707b15.zip
fixes #262 NNG_OPT_URL should be resolved
This causes TCP, TLS, and ZT endpoints to resolve any wildcards, and even IP addresses, when reporting the listen URL. The dialer URL is reported unresolved. Test cases for this are added as well, and nngcat actually reports this if --verbose is supplied.
Diffstat (limited to 'tests/tcp.c')
-rw-r--r--tests/tcp.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/tcp.c b/tests/tcp.c
index ef572c9d..42be028d 100644
--- a/tests/tcp.c
+++ b/tests/tcp.c
@@ -80,6 +80,25 @@ TestMain("TCP Transport", {
So(nng_dial(s2, addr, NULL, 0) == 0);
});
+ Convey("We can bind to port zero", {
+ nng_socket s1;
+ nng_socket s2;
+ nng_listener l;
+ char addr[NNG_MAXADDRLEN];
+ size_t sz;
+
+ So(nng_pair_open(&s1) == 0);
+ So(nng_pair_open(&s2) == 0);
+ Reset({
+ nng_close(s2);
+ nng_close(s1);
+ });
+ So(nng_listen(s1, "tcp://127.0.0.1:0", &l, 0) == 0);
+ sz = NNG_MAXADDRLEN;
+ So(nng_listener_getopt(l, NNG_OPT_URL, addr, &sz) == 0);
+ So(nng_dial(s2, addr, NULL, 0) == 0);
+ });
+
Convey("Malformed TCP addresses do not panic", {
nng_socket s1;