diff options
| -rw-r--r-- | docs/man/nng_close.3.adoc | 9 | ||||
| -rw-r--r-- | include/nng/nng.h | 6 | ||||
| -rw-r--r-- | src/nng.c | 8 |
3 files changed, 20 insertions, 3 deletions
diff --git a/docs/man/nng_close.3.adoc b/docs/man/nng_close.3.adoc index 1867df07..827bf929 100644 --- a/docs/man/nng_close.3.adoc +++ b/docs/man/nng_close.3.adoc @@ -1,6 +1,6 @@ = nng_close(3) // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2025 Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This document is supplied under the terms of the MIT License, a @@ -20,14 +20,19 @@ nng_close - close socket #include <nng/nng.h> int nng_close(nng_socket s); +int nng_socket_close(nng_socket s); ---- == DESCRIPTION -The `nng_close()` function closes the supplied socket, _s_. +The `nng_socket_close()` function closes the supplied socket, _s_. Messages that have been submitted for sending may be flushed or delivered, depending upon the transport. +The `nng_close()` function also does this, and is the old name for this +function. The `nng_close()` function is considered deprecated and may +be removed in the next major release. + Further attempts to use the socket after this call returns will result in `NNG_ECLOSED`. Threads waiting for operations on the socket when this diff --git a/include/nng/nng.h b/include/nng/nng.h index b496b343..6db41a85 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -223,8 +223,14 @@ NNG_DECL void nng_fini(void); // nng_close closes the socket, terminating all activity and // closing any underlying connections and releasing any associated // resources. +// We're not eliding this with NNG_ELIDE_DEPRECATED for now, because +// it would break far too many applications, as nng_socket_close is brand new. NNG_DECL int nng_close(nng_socket); +// nng_socket_close is the *new* name for nng_close. It should be used +// in new code, as nng_close will be removed in the next major release. +NNG_DECL int nng_socket_close(nng_socket); + // nng_socket_id returns the positive socket id for the socket, or -1 // if the socket is not valid. NNG_DECL int nng_socket_id(nng_socket); @@ -32,7 +32,7 @@ nng_fini(void) } int -nng_close(nng_socket s) +nng_socket_close(nng_socket s) { int rv; nni_sock *sock; @@ -48,6 +48,12 @@ nng_close(nng_socket s) } int +nng_close(nng_socket s) +{ + return (nng_socket_close(s)); +} + +int nng_socket_id(nng_socket s) { return (((int) s.id > 0) ? (int) s.id : -1); |
