NN_SYMBOL_INFO(3)
π 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 themselvestypeβ the option type, for socket option constantsunitβ 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 theNN_MSGsymbol is not exported by thenn_symbol_infofunction. 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 theNN_NS_*constants themselves πNN_NS_VERSIONβ Nanomsg version constantsNN_NS_DOMAINβ Socket domain (or address family) constantsAF_SP,AF_SP_RAWNN_NS_TRANSPORTβ Transport name constants (used for socket options mainly)NN_NS_PROTOCOLβ Socket protocol constantsNN_NS_OPTION_LEVELβ Socket option level constants (NN_SOL_SOCKET)NN_NS_SOCKET_OPTIONβ Socket options forNN_SOL_SOCKETlevelNN_NS_TRANSPORT_OPTIONβ Socket options for transport level (used with transport constants)NN_NS_OPTION_TYPEβ The option types (described below π)NN_NS_FLAGβ Thenn_send/nn_recvflags (onlyNN_DONTWAITfor now)NN_NS_ERRORβ TheerrnovaluesNN_NS_LIMITβ Various nanomsg limits (onlyNN_SOCKADDR_MAXfor now)NN_NS_EVENTβ Event flags (bit mask) for use withnn_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 optionsNN_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 from1to16NN_UNIT_BOOLEANβ The option value is boolean, an integer0or1β
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
iis valid, returns the number of bytes stored at the structure. The maximum value that can be returned isbuflen. - If
iis out-of-range,nn_symbol_inforeturns 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
- fedora 44: nanomsg-devel 1.2.2-2.fc44 Β· MIT
- fedora 44: nanomsg-devel 1.2.2-2.fc44 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms