summaryrefslogtreecommitdiff
path: root/src/sp/protocol
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-09 08:32:33 -0800
committerGarrett D'Amore <garrett@damore.org>2024-11-11 10:31:44 -0800
commitdb5467e6c3b502f6e93a6f6c5d1f2a8f86a8eaa5 (patch)
tree71fb23ed0f0e2eb980245fcdf72cf2fce5d152be /src/sp/protocol
parent768eaa4d50a6a436b714188ec9c6b98fd729b306 (diff)
downloadnng-db5467e6c3b502f6e93a6f6c5d1f2a8f86a8eaa5.tar.gz
nng-db5467e6c3b502f6e93a6f6c5d1f2a8f86a8eaa5.tar.bz2
nng-db5467e6c3b502f6e93a6f6c5d1f2a8f86a8eaa5.zip
Add new functions for socket identity.
These functions were added in the main branch for NNG 2.0, and we add them here to facilitate converting any code that happened to use the options (`NNG_OPT_PROTO`, `NNG_OPT_PROTONAME`, `NNG_OPT_PEER`, `NNG_OPT_PEERNAME`, and `NNG_OPT_RAW`. Its unlikely that many applications need this, but providing these as a transition aid may help applications start adopting new APIs now.
Diffstat (limited to 'src/sp/protocol')
-rw-r--r--src/sp/protocol/bus0/bus_test.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/sp/protocol/bus0/bus_test.c b/src/sp/protocol/bus0/bus_test.c
index 6a214972..f9c1c092 100644
--- a/src/sp/protocol/bus0/bus_test.c
+++ b/src/sp/protocol/bus0/bus_test.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -16,21 +16,19 @@
void
test_bus_identity(void)
{
- nng_socket s;
- int p;
- char *n;
+ nng_socket s;
+ uint16_t p;
+ const char *n;
NUTS_PASS(nng_bus0_open(&s));
- NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p));
+ NUTS_PASS(nng_socket_proto_id(s, &p));
NUTS_TRUE(p == NNG_BUS0_SELF);
- NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PEER, &p));
+ NUTS_PASS(nng_socket_peer_id(s, &p));
NUTS_TRUE(p == NNG_BUS0_PEER); // 49
- NUTS_PASS(nng_socket_get_string(s, NNG_OPT_PROTONAME, &n));
+ NUTS_PASS(nng_socket_proto_name(s, &n));
NUTS_MATCH(n, NNG_BUS0_SELF_NAME);
- nng_strfree(n);
- NUTS_PASS(nng_socket_get_string(s, NNG_OPT_PEERNAME, &n));
+ NUTS_PASS(nng_socket_peer_name(s, &n));
NUTS_MATCH(n, NNG_BUS0_PEER_NAME);
- nng_strfree(n);
NUTS_CLOSE(s);
}
@@ -70,7 +68,7 @@ test_bus_device(void)
{
nng_socket s1, s2, s3;
nng_socket none = NNG_SOCKET_INITIALIZER;
- nng_aio *aio;
+ nng_aio *aio;
NUTS_PASS(nng_bus0_open_raw(&s1));
NUTS_PASS(nng_bus0_open(&s2));
@@ -372,6 +370,8 @@ test_bus_cooked(void)
bool b;
NUTS_PASS(nng_bus0_open(&s));
+ NUTS_PASS(nng_socket_raw(s, &b));
+ NUTS_TRUE(!b);
NUTS_PASS(nng_socket_get_bool(s, NNG_OPT_RAW, &b));
NUTS_TRUE(!b);
NUTS_FAIL(nng_socket_set_bool(s, NNG_OPT_RAW, true), NNG_EREADONLY);