From db5467e6c3b502f6e93a6f6c5d1f2a8f86a8eaa5 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 9 Nov 2024 08:32:33 -0800 Subject: 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. --- src/sp/protocol/bus0/bus_test.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/sp/protocol') 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. +// Copyright 2024 Staysail Systems, Inc. // // 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); -- cgit v1.2.3-70-g09d2