NN_SYMBOL_INFO(3)

πŸ“¦
version 1.2.2 Β· 5 versions
, in fedora 44

πŸ’– NN_SYMBOL_INFO β€” bestie's guide to querying nanomsg symbols πŸ’–

okay so this is the nanomsg 1.2.2 manual page for nn_symbol_info, which is a <nanomsg/nn.h> situation. yes it's a manual page. yes it's giving reference documentation. and yes, we're gonna make it make sense. 🫢


✨ NAME ✨

nn_symbol_info β€” query the names and properties of nanomsg symbols πŸ’…

like, you wanna know what a symbol is called and what it's worth? this is the function. that's the whole job. iconic behavior honestly.


✨ SYNOPSIS ✨

#include <nanomsg/nn.h>

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

look at that signature. three arguments. no drama. we love a clean prototype. 🌸


✨ DESCRIPTION ✨

So basically: this function retrieves the symbol name and value at index i. πŸ’«

Indices start at 0. And here's the tea β€” an index has no significance to its associated symbol. the mappings may change between library versions. so like, do NOT hardcode index 7 expecting it to be the same symbol forever, bestie, that's a situationship with the ABI and it will not end well. 😭

The nn_symbol_properties struct 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;
};

okay so let's break down the members because each one is carrying its own weight:

  • value β€” the constant value πŸ’œ
  • name β€” the constant name ✨
  • ns β€” the constant namespace, or zero for namespaces themselves
  • type β€” the option type, for socket option constants
  • unit β€” the unit for the option value, for socket option constants

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. πŸ”₯ that's the good stuff. future-proofed. main character energy.

Typically a client will iterate through the symbols until nn_symbol_info returns NULL in order to collect all the symbols. πŸ¦‹ (yes, the manpage says NULL. we're just the messenger.)

All symbols exposed by nn_symbol_info are available directly in the C API, generally as preprocessor macros. So this function is useful mostly for language bindings that can't parse the header file and rely on retrieving the symbols at runtime. 🧚 basically: if you're writing a binding in some language that can't just #include a C header, this is your girl.

⚠️ 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). πŸ’€ so don't come looking for it here, it's not ghosting you on purpose, it's just not an integer and that's a whole thing.

🌈 AVAILABLE NAMESPACES 🌈

these are the ns values you might see. collect them all like PokΓ©mon cards. πŸŽ€

  • NN_NS_NAMESPACE β€” Equals to zero and denotes the NN_NS_* constants themselves πŸ‘‘
  • NN_NS_VERSION β€” Nanomsg version constants
  • NN_NS_DOMAIN β€” Socket domain (or address family) constants AF_SP, AF_SP_RAW
  • NN_NS_TRANSPORT β€” Transport name constants (used for socket options mainly)
  • NN_NS_PROTOCOL β€” Socket protocol constants
  • NN_NS_OPTION_LEVEL β€” Socket option level constants (NN_SOL_SOCKET)
  • NN_NS_SOCKET_OPTION β€” Socket options for NN_SOL_SOCKET level
  • NN_NS_TRANSPORT_OPTION β€” Socket options for transport level (used with transport constants)
  • NN_NS_OPTION_TYPE β€” The option types (described below πŸ‘‡)
  • NN_NS_FLAG β€” The nn_send/nn_recv flags (only NN_DONTWAIT for now)
  • NN_NS_ERROR β€” The errno values
  • NN_NS_LIMIT β€” Various nanomsg limits (only NN_SOCKADDR_MAX for now)
  • NN_NS_EVENT β€” Event flags (bit mask) for use with nn_poll (NN_POLLIN, NN_POLLOUT)

⭐ AVAILABLE OPTION TYPES ⭐

this is the type field's whole personality. πŸ’…

  • NN_TYPE_NONE β€” No type, is returned for constants that are not socket options
  • NN_TYPE_INT β€” The integer type πŸ”’
  • NN_TYPE_STR β€” 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. πŸ¦‹ cute, right? the function tells you about its own options. self-aware king behavior.


πŸ“ AVAILABLE OPTION UNITS πŸ“

and this is the unit field, because numbers without units are just vibes. πŸ™ˆ

  • NN_UNIT_NONE β€” No unit, is returned for constants that are not socket options, or do not have any meaningful unit (strings, integer values)
  • NN_UNIT_BYTES β€” The option value is expressed in bytes πŸ“
  • NN_UNIT_MILLISECONDS β€” The option value is expressed in milliseconds ⏱️
  • NN_UNIT_PRIORITY β€” The option value is a priority, an integer from 1 to 16
  • NN_UNIT_BOOLEAN β€” 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. (yes it's the same line as before. the manpage said it twice, so we say it twice. consistency bestie. πŸ’–)


πŸ’« 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. πŸ«₯

so like, zero means "nothing here, move along". any other number is your byte count. no cap.


πŸŽ€ EXAMPLE πŸŽ€

here's the canonical loop. it's a bop. literally just walk the indices until you hit a zero. 🌟

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

see how rc == 0 is the exit condition? that's the whole trick. then assert (rc == sizeof (sym)) makes sure you got the full struct back. slay. πŸ”₯


πŸ’œ SEE ALSO πŸ’œ


πŸ‘‘ AUTHORS πŸ‘‘

this page was written by:

  • Paul Colomiets <paul@colomiets.name>
  • Garrett D'Amore <garrett@damore.org>

absolute legends. thank you for your service. 🫢


and that's the whole page, bestie!! this was NN_SYMBOL_INFO(3) from nanomsg 1.2.2, dated 2026-01-16. go forth and enumerate your symbols responsibly. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from