diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-12-31 14:52:49 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-12-31 14:52:49 -0800 |
| commit | f0cf75a487aff2ecaeda290b51d77c4e8cccb061 (patch) | |
| tree | 42dca046cc108bf63905751373ae9f96d69c82d3 | |
| parent | 5fb0d00d9e69e80fe8dc65270316bfc416a0e0d3 (diff) | |
| download | nng-f0cf75a487aff2ecaeda290b51d77c4e8cccb061.tar.gz nng-f0cf75a487aff2ecaeda290b51d77c4e8cccb061.tar.bz2 nng-f0cf75a487aff2ecaeda290b51d77c4e8cccb061.zip | |
docs: convert nng_stream_get family
| -rw-r--r-- | docs/man/nng_stream_get.3str.adoc | 110 | ||||
| -rw-r--r-- | docs/ref/api/stream.md | 28 | ||||
| -rw-r--r-- | docs/ref/xref.md | 8 |
3 files changed, 36 insertions, 110 deletions
diff --git a/docs/man/nng_stream_get.3str.adoc b/docs/man/nng_stream_get.3str.adoc deleted file mode 100644 index a7137ecb..00000000 --- a/docs/man/nng_stream_get.3str.adoc +++ /dev/null @@ -1,110 +0,0 @@ -= nng_stream_get(3str) -// -// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// Copyright 2019 Devolutions <info@devolutions.net> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_stream_get - get option from byte stream - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -int nng_stream_get_bool(nng_stream *s, const char *opt, bool *valp); - -int nng_stream_get_int(nng_stream *s, const char *opt, int *valp); - -int nng_stream_get_ms(nng_stream *s, const char *opt, nng_duration *valp); - -int nng_stream_get_size(nng_stream *s, const char *opt, size_t *valp); - -int nng_stream_get_addr(nng_stream *s, const char *opt, nng_sockaddr *valp); - -int nng_stream_get_string(nng_stream *s, const char *opt, char **valp); - -int nng_stream_get_uint64(nng_stream *s, const char *opt, uint64_t *valp); ----- - -== DESCRIPTION - -The `nng_stream_get` functions are used to retrieve option values for the -xref:nng_stream.5.adoc[byte stream] _conn_. - -The actual options that may be retrieved in this way vary. -A number of them are documented in -xref:nng_options.5.adoc[nng_options(5)] and additional linked documents. - -=== Forms - -In all of these forms, the option _opt_ is retrieved from the connected -byte stream _s_. -The forms vary based on the type of the option they take. - -The details of the type, size, and semantics of the option will depend -on the actual option, and will be documented with the option itself. - -`nng_stream_get_bool()`:: -This function is for options which take a Boolean (`bool`). - -`nng_stream_get_int()`:: -This function is for options which take an integer (`int`). - -`nng_stream_get_ms()`:: -This function is used to retrieve time -xref:nng_duration.5.adoc[durations] -(such as timeouts), stored as a number of milliseconds. -(The special value ((`NNG_DURATION_INFINITE`)) means an infinite amount of time, and -the special value ((`NNG_DURATION_DEFAULT`)) means a context-specific default.) - -`nng_stream_get_size()`:: -This function is used to retrieve a size, -typically for buffer sizes, message maximum sizes, and similar options. - -`nng_stream_get_addr()`:: -This function is used to retrieve a -xref:nng_sockaddr.5.adoc[socket address]. - -`nng_stream_get_string()`:: -This function is used to retrieve a `NULL`-terminated string. -This string is created from the source using -xref:nng_strdup.3.adoc[`nng_strdup()`] -and consequently must be freed by the caller using -xref:nng_strfree.3.adoc[`nng_strfree()`] when it is no longer needed. - -`nng_stream_get_uint64()`:: -This function is used to retrieve a 64-bit unsigned value. -This is typically used for identifiers, network -numbers, and similar options. - -== RETURN VALUES - -This function returns 0 on success, and non-zero otherwise. - -== ERRORS - -[horizontal] -`NNG_ECLOSED`:: The connection is closed. -`NNG_EINVAL`:: There was insufficient space to receive the object. - The amount of data actually needed is returned in _sizep_. -`NNG_ENOTSUP`:: The option is not supported. -`NNG_EWRITEONLY`:: The option may not read. - -== SEE ALSO - -[.text-left] -xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng_options.5.adoc[nng_options(5)], -xref:nng_ipc_options.5.adoc[nng_ipc_options(5)], -xref:nng_tcp_options.5.adoc[nng_tcp_options(5)], -xref:nng_tls_options.5.adoc[nng_tls_options(5)], -xref:nng_stream.5.adoc[nng_stream(5)] diff --git a/docs/ref/api/stream.md b/docs/ref/api/stream.md index 9609ef7b..37275c93 100644 --- a/docs/ref/api/stream.md +++ b/docs/ref/api/stream.md @@ -76,4 +76,32 @@ stream itself. > or be aborted, these functions are unsafe to call from functions that may not block, such as the > completion function registered with an [`nng_aio`] when it is created. +## Getting Stream Options + +```c +int nng_stream_get_bool(nng_stream *s, const char *opt, bool *valp); +int nng_stream_get_int(nng_stream *s, const char *opt, int *valp); +int nng_stream_get_ms(nng_stream *s, const char *opt, nng_duration *valp); +int nng_stream_get_size(nng_stream *s, const char *opt, size_t *valp); +int nng_stream_get_addr(nng_stream *s, const char *opt, nng_sockaddr *valp); +int nng_stream_get_string(nng_stream *s, const char *opt, char **valp); +int nng_stream_get_uint64(nng_stream *s, const char *opt, uint64_t *valp); +``` + +{{hi:`nng_stream_get_bool`}} +{{hi:`nng_stream_get_int`}} +{{hi:`nng_stream_get_ms`}} +{{hi:`nng_stream_get_size`}} +{{hi:`nng_stream_get_addr`}} +{{hi:`nng_stream_get_string`}} +{{hi:`nng_stream_get_uint64`}} +These functions are used to obtain value of an option named _opt_ from the stream _s_, and store it in the location +referenced by _valp_. + +These functions access an option as a specific type. The transport layer will have details about which options +are available, and which type they may be accessed using. + +In the case of `nng_stream_get_string`, the string is created as if by [`nng_strdup`], and must be freed by +the caller using [`nng_strfree`] when no longer needed. + {{#include ../xref.md}} diff --git a/docs/ref/xref.md b/docs/ref/xref.md index b790dcbd..355ebe37 100644 --- a/docs/ref/xref.md +++ b/docs/ref/xref.md @@ -109,6 +109,14 @@ [`nng_stream_close`]: /api/stream.md#closing-a-stream [`nng_stream_stop`]: /api/stream.md#closing-a-stream [`nng_stream_free`]: /api/stream.md#closing-a-stream +[`nng_stream_get`]: /api/stream.md#getting-stream-options +[`nng_stream_get_bool`]: /api/stream.md#getting-stream-options +[`nng_stream_get_int`]: /api/stream.md#getting-stream-options +[`nng_stream_get_ms`]: /api/stream.md#getting-stream-options +[`nng_stream_get_size`]: /api/stream.md#getting-stream-options +[`nng_stream_get_addr`]: /api/stream.md#getting-stream-options +[`nng_stream_get_string`]: /api/stream.md#getting-stream-options +[`nng_stream_get_uint64`]: /api/stream.md#getting-stream-options [`nng_init`]: /api/init.md#initialization [`nng_fini`]: /api/init.md#finalization [`nng_sub0_ctx_subscribe`]: /TODO.md |
