nn_symbol_info - Man Page

query the names and properties of nanomsg symbols


#include <nanomsg/nn.h>

int nn_symbol_info (int i, struct nn_symbol_properties *buf, int buflen);


Retrieves the symbol name and value at index i.  Indices start at 0.  An index has no significance to its associated symbol; the mappings may change between library versions.

The nn_symbol_properties has the following definition:

struct nn_symbol_properties {

    /*  The constant value  */
    int value;

    /*  The constant name  */
    const char* name;

    /*  The constant namespace, or zero for namespaces themselves */
    int ns;

    /*  The option type for socket option constants  */
    int type;

    /*  The unit for the option value for socket option constants  */
    int unit;

More structure members may be added in future, but the input pointer will be written only up to buflen so the ABI is forward-compatible.

Typically a client will iterate through the symbols until nn_symbol_info returns NULL in order to collect all the symbols.

All symbols exposed by nn_symbol_info are available directly in the C API, generally as preprocessor macros.  Thus, this function is useful mostly for language bindings that can’t parse the header file and rely on retrieving the symbols at runtime.

Note that the NN_MSG symbol is not exported by the nn_symbol_info function. First, it is a pointer rather than an integer; second, the symbol is not supposed to be exported from language bindings to the user. Instead, language bindings should provide the zero-copy functionality in a language-specific way, if at all (zero-copy functionality may not make sense for some languages/bindings).

Available Namespaces


Equals to zero and denotes the NN_NS_* constants themselves


Nanomsg version constants


Socket domain (or address family) constants AF_SP, AF_SP_RAW


Transport name constants (used for socket options mainly)


Socket protocol constants


Socket option level constants (NN_SOL_SOCKET)


Socket options for NN_SOL_SOCKET level


Socket options for transport level (used with transport constants)


The option types (described below)


The nn_send/nn_recv flags (only NN_DONTWAIT for now)


The errno values


Various nanomsg limits (only NN_SOCKADDR_MAX for now)


Event flags (bit mask) for use with nn_poll (NN_POLLIN, NN_POLLOUT)

Available Option Types


No type, is returned for constants that are not socket options


The integer type


String (char *) type

More types may be added in the future to nanomsg. You may enumerate all of them using the nn_symbol_info itself by checking NN_NS_OPTION_TYPE namespace.

Available Option Units


No unit, is returned for constants that are not socket options, or do not have any meaningful unit (strings, integer values)


The option value is expressed in bytes


The option value is expressed in milliseconds


The option value is a priority, an integer from 1 to 16


The option value is boolean, an integer 0 or 1

More types may be added in the future to nanomsg. You may enumerate all of them using the nn_symbol_info itself by checking NN_NS_OPTION_TYPE namespace.

Return Value

If i is valid, returns the number of bytes stored at the structure. The maximum value that can be returned is buflen.

If i is out-of-range, nn_symbol_info returns zero.


int i;
for (i = 0; ; ++i) {
    struct nn_symbol_properties sym;
    int rc = nn_symbol_info (i, &sym, sizeof (sym));
    if(rc == 0)
    assert (rc == sizeof (sym));
    printf ("'%s' = %d\n", sym.name, sym.value);

See Also

nn_symbol(3) nn_errno(3) nn_strerror(3) nanomsg(7)


Paul Colomiets Garrett D’Amore

Referenced By

nanomsg(7), nn_symbol(3).

2023-01-19 nanomsg 1.1.5