aboutsummaryrefslogtreecommitdiff
path: root/tests/tcp.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-12-29 21:28:49 -0800
committerGarrett D'Amore <garrett@damore.org>2018-12-31 17:10:04 -0800
commita73ff5363eae228009413872b05aff758a46c5ca (patch)
treed5fa805188f915fc94c9b80d4f5cbbb96e6a4551 /tests/tcp.c
parente0fff1f9c45f5486fc2e7eeb49b4462c3bb2dad4 (diff)
downloadnng-a73ff5363eae228009413872b05aff758a46c5ca.tar.gz
nng-a73ff5363eae228009413872b05aff758a46c5ca.tar.bz2
nng-a73ff5363eae228009413872b05aff758a46c5ca.zip
fixes #825 TCP public API should use generic setopt/getopt
This changes much of the internal API for TCP option handling, and includes hooks for some of this in various consumers. Note that the consumers still need to have additional work done to complete them, which will be part of providing public "raw" TLS and WebSocket APIs. We would also like to finish addressing the call sites of nni_tcp_listener_start() that assume the sockaddr is modified -- it would be superior to use the NNG_OPT_LOCADDR option. Thaat will be addressed in a follow up PR.
Diffstat (limited to 'tests/tcp.c')
-rw-r--r--tests/tcp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/tcp.c b/tests/tcp.c
index 53372fa5..8975da33 100644
--- a/tests/tcp.c
+++ b/tests/tcp.c
@@ -1,6 +1,7 @@
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 Devolutions <info@devolutions.net>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -93,6 +94,7 @@ TestMain("TCP Transport", {
Convey("We can bind to port zero", {
nng_socket s1;
nng_socket s2;
+ nng_sockaddr sa;
nng_listener l;
char * addr;
@@ -105,6 +107,10 @@ TestMain("TCP Transport", {
So(nng_listen(s1, "tcp://127.0.0.1:0", &l, 0) == 0);
So(nng_listener_getopt_string(l, NNG_OPT_URL, &addr) == 0);
So(memcmp(addr, "tcp://", 6) == 0);
+ So(nng_listener_getopt_sockaddr(l, NNG_OPT_LOCADDR, &sa) == 0);
+ So(sa.s_in.sa_family == NNG_AF_INET);
+ So(sa.s_in.sa_port != 0);
+ So(sa.s_in.sa_addr = htonl(0x7f000001));
So(nng_dial(s2, addr, NULL, 0) == 0);
nng_strfree(addr);
});