This documentation is for version v1.3.0 of NNG, but the latest released version is v1.8.0. see the documentation for v1.8.0 for the most up-to-date information.


#include <nng/nng.h>
#include <nng/supplemental/tls/tls.h>

typedef struct nng_tls_s nng_tls;


An nng_tls represents a connected stream. TLS stream objects can be used to send or receive data, and provide transport level security via cryptography over a TCP connected stream.

The nng_tls object is used for raw TLS connections, and should not be confused with a pipe object created using the nng_tls(7) transport.
Most NNG applications should not use this, but instead use the nng_tls(7) transport instead.

These objects are created either establishing an outgoing connection with nng_tls_dialer_dial() or by accepting in incoming connection with nng_tls_listener_accept().

TLS connections are byte streams, and are “reliable” in that data will not be delivered out of order, or with portions missing.

Data can be sent using nng_tls_send() or received with nng_tls_recv().

When the connection is no longer needed, it should be freed with nng_tls_free().

It is possible to close the connection, without freeing it, by using nng_tls_close().


The following options are applicable to TLS connections, and may be accessed using the nng_tls_getopt() and nng_tls_setopt() functions.

Other platform specific options may be available as well.