From fd320bbff94ed12a9db8e2ccb250dfa0d333f04c Mon Sep 17 00:00:00 2001
From: gdamore
nng_aio when it is created.
+const nng_sockaddr *nng_stream_peer_addr(nng_stream *s);
+const nng_sockaddr *nng_stream_self_addr(nng_stream *s);
+
++ +These functions are used to obtain value of the local (self) or remote (peer) addresses +for the given stream s.
nng_err nng_stream_get_bool(nng_stream *s, const char *opt, bool *valp);
nng_err nng_stream_get_int(nng_stream *s, const char *opt, int *valp);
@@ -320,41 +328,46 @@ nng_err nng_stream_get_size(nng_stream *s, const char *opt, size_t *valp);
nng_err nng_stream_get_addr(nng_stream *s, const char *opt, nng_sockaddr *valp);
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_addrfunction is deprecated and will be removed. Use the +nng_stream_peer_addrornng_stream_self_addrfunctions instead.
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.
socket and then calling connect on them.
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.
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.
@@ -390,7 +403,7 @@ callbacks are running that could reference an object after it is deallocated.
Making Outgoing Connectionsvoid 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.
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.
@@ -506,6 +517,8 @@ 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.
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
need not retain the value referenced once the function returns.
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.
@@ -548,13 +561,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