From 6274913455be87cbe598b5d0534e1e80972c8efd Mon Sep 17 00:00:00 2001 From: gdamore Date: Tue, 28 Oct 2025 05:39:18 +0000 Subject: deploy: 1d69c8f0393337d4f222cc1af1af813d77922c84 --- ref/api/stream.html | 54 ++++++++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) (limited to 'ref/api/stream.html') diff --git a/ref/api/stream.html b/ref/api/stream.html index d7ce936f..9411bac8 100644 --- a/ref/api/stream.html +++ b/ref/api/stream.html @@ -333,41 +333,35 @@ nng_err nng_stream_get_string(nng_stream *s, const char *opt, const char **valp) - 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 pointer is only guaranteed to be valid while the stream exists. Callers should make a copy of the data if required before closing the stream.

-
-

[!NOTE]: -The nng_stream_get_addr function is deprecated and will be removed. Use the -nng_stream_peer_addr or nng_stream_self_addr functions instead.

-

Stream Factories

typedef struct nng_stream_dialer nng_stream_dialer;
 typedef struct nng_stream_listener nng_stream_listener;
 
-

-The nng_stream_listener object and nng_stream_listener objects can be thought of as factories that +

+The nng_stream_listener object and nng_stream_listener objects can be thought of as factories that create nng_stream streams.

The nng_stream_listener object a handle to a listener, which creates streams by accepting incoming connection requests. -In a BSD socket implementation, this is the entity responsible for doing bind, listen and accept. +In a BSD socket implementation, this is the entity responsible for doing bind, listen and accept. Normally a listener may be used to accept multiple, possibly many, concurrent connections.

The nng_stream_dialer object is a handle to a dialer, which creates streams by making outgoing connection requests. While there isn’t a specific BSD socket analogue, this can be thought of as a factory for TCP sockets -created by opening them with socket and then calling connect on them.

+created by opening them with socket and then calling connect on them.

Creating a Stream Factory

nng_err nng_stream_dialer_alloc(nng_stream_dialer **dialerp, const char *url);
 nng_err nng_stream_dialer_alloc_url(nng_stream_dialer **dialerp, const nng_url *url);
 nng_err nng_stream_listener_alloc(nng_stream_listener **lstenerp, const char *url);
 nng_err nng_stream_listener_alloc_url(nng_stream_listener **listenerp, const nng_url *url);
 
-

The nng_stream_dialer_alloc and nng_stream_dialer_alloc_url functions create a stream dialer, associated the -URL specified by url represented as a string, or as an nng_url object, respectively. The dialer is returned in the location +

The nng_stream_dialer_alloc and nng_stream_dialer_alloc_url functions create a stream dialer, associated the +URL specified by url represented as a string, or as an nng_url object, respectively. The dialer is returned in the location dialerp references.

-

The nng_stream_listener_alloc and nng_stream_listener_alloc_url functions create a stream listener, associated the +

The nng_stream_listener_alloc and nng_stream_listener_alloc_url functions create a stream listener, associated the URL specified by url represented as a string, or as an nng_url object, respectively. The listener is returned in the location listenerp references.

Example 1: Creating a TCP Listener

@@ -383,14 +377,14 @@ void nng_stream_listener_close(nng_stream_listener *listener); void nng_stream_listener_stop(nng_stream_listener *listener); void nng_stream_listener_free(nng_stream_listener *listener); -

The nng_stream_dialer_close and nng_stream_listener_close functions close the stream dialer or listener, +

The nng_stream_dialer_close and nng_stream_listener_close functions close the stream dialer or listener, preventing it from creating new connections. This will generally include closing any underlying file used for creating such connections. However, some requests may still be pending when this function returns, as it does not wait for the shutdown to complete.

-

The nng_stream_dialer_stop and nng_stream_listener_stop functions performs the same action, +

The nng_stream_dialer_stop and nng_stream_listener_stop functions performs the same action, but also wait until all outstanding requests are serviced, and the dialer or listener is completely stopped. Because they blocks, these functions must not be called in contexts where blocking is not allowed.

-

The nng_stream_dialer_free and nng_stream_listener_free function performs the same action as +

The nng_stream_dialer_free and nng_stream_listener_free function performs the same action as nng_stream_dialer_stop or nng_stream_listener_stop, but also deallocates the dialer or listener, and any associated resources.

@@ -403,7 +397,7 @@ callbacks are running that could reference an object after it is deallocated.

Making Outgoing Connections
void nng_stream_dialer_dial(nng_stream_dialer *dialer, nng_aio *aio);
 
-

The nng_stream_dialer_dial initiates an outgoing connection asynchronously, using the nng_aio aio. +

The nng_stream_dialer_dial initiates an outgoing connection asynchronously, using the nng_aio aio. If it successfully establishes a connection, it creates an nng_stream, which can be obtained as the first output result on aio using the nng_aio_get_output function with index zero.

@@ -437,10 +431,10 @@ stream = nng_aio_get_output(aio, 0);
nng_err nng_stream_listener_listen(nng_stream_listener *listener);
 void nng_stream_listener_accept(nng_stream_listener *listener, nng_aio *aio);
 
-

Accepting incoming connections is performed in two steps. The first step, nng_stream_listener_listen is to setup for +

Accepting incoming connections is performed in two steps. The first step, nng_stream_listener_listen is to setup for listening. For a TCP implementation of this, for example, this would perform the bind and the listen steps. This will bind to the address represented by the URL that was specific when the listener was created with nng_stream_listener_alloc.

-

In the second step, nng_stream_listener_accept accepts an incoming connection on listener asynchronously, using the nng_aio aio. +

In the second step, nng_stream_listener_accept accepts an incoming connection on listener asynchronously, using the nng_aio aio. If an incoming connection is accepted, it will be represented as an nng_stream, which can be obtained from the aio as the first output result using the nng_aio_get_output function with index zero.

Example 3: Accepting an Inbound Stream

@@ -467,14 +461,12 @@ if (nng_aio_result(aio) != 0) { stream = nng_aio_get_output(aio, 0);

Stream Factory Options

-
nng_err nng_stream_dialer_get_addr(nng_stream_dialer *dialer, const char *opt, nng_sockaddr *valp);
-nng_err nng_stream_dialer_get_bool(nng_stream_dialer *dialer, const char *opt, bool *valp);
+
nng_err nng_stream_dialer_get_bool(nng_stream_dialer *dialer, const char *opt, bool *valp);
 nng_err nng_stream_dialer_get_int(nng_stream_dialer *dialer, const char *opt, int *valp);
 nng_err nng_stream_dialer_get_ms(nng_stream_dialer *dialer, const char *opt, nng_duration *valp);
 nng_err nng_stream_dialer_get_size(nng_stream_dialer *dialer, const char *opt, size_t *valp);
 nng_err nng_stream_dialer_get_string(nng_stream_dialer *dialer, const char *opt, const char **valp);
 
-nng_err nng_stream_listener_get_addr(nng_stream_listener *listener, const char *opt, nng_sockaddr *valp);
 nng_err nng_stream_listener_get_bool(nng_stream_listener *listener, const char *opt, bool *valp);
 nng_err nng_stream_listener_get_int(nng_stream_listener *listener, const char *opt, int *valp);
 nng_err nng_stream_listener_get_ms(nng_stream_listener *listener, const char *opt, nng_duration *valp);
@@ -488,14 +480,14 @@ nng_err nng_stream_dialer_set_ms(nng_stream_dialer *dialer, const char *opt, nng
 nng_err nng_stream_dialer_set_size(nng_stream_dialer *dialer, const char *opt, size_t val);
 nng_err nng_stream_dialer_set_string(nng_stream_dialer *dialer, const char *opt, const char *val);
 
-nng_err nng_stream_listener_set_addr(nng_stream_listener *listener, const char *opt, const nng_sockaddr *val);
 nng_err nng_stream_listener_set_bool(nng_stream_listener *listener, const char *opt, bool val);
 nng_err nng_stream_listener_set_int(nng_stream_listener *listener, const char *opt, int val);
 nng_err nng_stream_listener_set_ms(nng_stream_listener *listener, const char *opt, nng_duration val);
 nng_err nng_stream_listener_set_size(nng_stream_listener *listener, const char *opt, size_t val);
 nng_err nng_stream_listener_set_string(nng_stream_listener *listener, const char *opt, const char *val);
 
-

+

+ @@ -517,8 +509,6 @@ nng_err nng_stream_listener_set_string(nng_stream_listener *listener, const char - - These functions are used to retrieve or change the value of an option named opt from the stream dialer or listener. The nng_stream_dialer_get_ and nng_stream_listener_get_ function families retrieve the value, and store it in the location valp references. The nng_stream_dialer_set_ and nng_stream_listener_set_ function families change the value for the dialer or listener, taking it from val.

@@ -528,12 +518,12 @@ are available, and which type they may be accessed using.

the string is only valid as long as the associated object remains open.

In the case of nng_stream_dialer_set_string and nng_stream_listener_set_string, the string contents are copied if necessary, so that the caller need not retain the value referenced once the function returns.

-

In the case of nng_stream_dialer_set_addr and nng_stream_listener_set_addr, the contents of addr are copied if necessary, so that the caller +

In the case of nng_stream_dialer_set_addr, the contents of addr are copied if necessary, so that the caller need not retain the value referenced once the function returns.

Example 4: Socket Activation

-

Some nng_stream_listener objects, depending on the underlying transport and platform, can support a technique known as “socket activation”, +

Some nng_stream_listener objects, depending on the underlying transport and platform, can support a technique known as “socket activation”, where the file descriptor used for listening and accepting is supplied externally, such as by a system service manager. -In this case, the application supplies the file descriptor or SOCKET object using the NNG_OPT_LISTEN_FD option, +In this case, the application supplies the file descriptor or SOCKET object using the NNG_OPT_LISTEN_FD option, instead of calling nng_stream_listener_listen.

@@ -561,13 +551,13 @@ nng_err nng_stream_dialer_set_tls(nng_stream_listener *dialer, nng_tls_config *t nng_err nng_stream_listener_get_tls(nng_stream_listener *listener, nng_tls_config **tlsp); nng_err nng_stream_listener_set_tls(nng_stream_listener *listener, nng_tls_config *tls);

-

Both nng_stream_dialer and nng_stream_listener objects may support configuration of TLS parameters. -The nng_stream_dialer_set_tls and nng_stream_listener_set_tls functions support setting the +

Both nng_stream_dialer and nng_stream_listener objects may support configuration of TLS parameters. +The nng_stream_dialer_set_tls and nng_stream_listener_set_tls functions support setting the configuration of a nng_tls_config object supplied by tls on dialer or listener. This must be performed before the listener starts listening with nng_stream_listener_listen, or the dialer starts an outgoing connection as a result of nng_stream_dialer_dial.

The configuration object that was previously established (which may be a default if one was not explicitly -configured) can be obtained with the nng_stream_dialer_get_tls and nng_stream_listener_get_tls. +configured) can be obtained with the nng_stream_dialer_get_tls and nng_stream_listener_get_tls. They will return a pointer to the nng_tls_config object in question at the location referenced by tlsp.

-- cgit v1.2.3-70-g09d2