nng_compat(3compat)
| NNG_COMPAT(3compat) | NNG Reference Manual | NNG_COMPAT(3compat) |
NAME
nng_compat - compatibility with nanomsg 1.0
SYNOPSIS
#include <nanomsg/nn.h> #include <nanomsg/bus.h> #include <nanomsg/pair.h> #include <nanomsg/pipeline.h> #include <nanomsg/pubsub.h> #include <nanomsg/reqrep.h> #include <nanomsg/survey.h> #include <nanomsg/inproc.h> #include <nanomsg/ipc.h> #include <nanomsg/tcp.h> #include <nanomsg/ws.h>
DESCRIPTION
NNG provides source-level compatibility for most libnanomsg 1.0 applications.
Important
This is intended to facilitate converting legacy applications to
use NNG. New applications should use the newer NNG API
instead.
Applications making use of this must take care to link with libnng instead of libnn.
Tip
While not recommended for long term use, the value returned by
nng_socket_id() can be used with these functions just
like a value returned by nn_socket(). This can be
way to facilitate incremental transition to the new API.
Note
Some capabilities, protocols, and transports, will not be
accessible
using this API, as the compatible API has no provision for expression of
certain concepts introduced in the new API.
Note
While reasonable efforts have been made to provide for
compatibility,
some things may behave differently, and some less common parts of the
libnanomsg 1.0 API are not supported at this time, including certain
options and the statistics API. See the Caveats section below.
Compiling
When compiling legacy nanomsg applications, it will generally be necessary to change the include search path to add the compat subdirectory of the directory where headers were installed. For example, if NNG is installed in $prefix, then header files will normally be located in $prefix/include/nng. In this case, to build legacy nanomsg apps against NNG you would add $prefix/include/nng/compat to your compiler’s search path.
Alternatively, you can change your source code so that #include statements referring to <nanomsg> instead refer to <nng/compat/nanomsg>. For example, instead of:
#include <nanomsg/nn.h> #include <nanomsg/reqrep.h>
you would have this:
#include <nng/compat/nanomsg/nn.h> #include <nng/compat/nanomsg/reqrep.h>
Legacy applications built using these methods should be linked against libnng instead of libnn, just like any other NNG application.
Functions
The following functions are provided:
nn_socket()
nn_getsockopt()
nn_setsockopt()
nn_bind()
nn_connect()
nn_send()
nn_recv()
nn_shutdown()
nn_close()
nn_poll()
nn_device()
nn_recvmsg()
nn_sendmsg()
nn_cmsg()
nn_get_statistic()
nn_allocmsg()
nn_reallocmsg()
nn_freemsg()
nn_errno()
nn_strerror()
nn_term()
Caveats
The following caveats apply when using the legacy API with NNG.
SEE ALSO
libnng(3), nng(7)
| 2026-06-29 |
