nn_symbol_info.adoc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. nn_symbol_info(3)
  2. =================
  3. NAME
  4. ----
  5. nn_symbol_info - query the names and properties of nanomsg symbols
  6. SYNOPSIS
  7. --------
  8. *#include <nanomsg/nn.h>*
  9. *int nn_symbol_info (int 'i', struct nn_symbol_properties '*buf', int 'buflen');*
  10. DESCRIPTION
  11. -----------
  12. Retrieves the symbol name and value at index 'i'. Indices start at 0. An index
  13. has no significance to its associated symbol; the mappings may change between
  14. library versions.
  15. The nn_symbol_properties has the following definition:
  16. ----
  17. struct nn_symbol_properties {
  18. /* The constant value */
  19. int value;
  20. /* The constant name */
  21. const char* name;
  22. /* The constant namespace, or zero for namespaces themselves */
  23. int ns;
  24. /* The option type for socket option constants */
  25. int type;
  26. /* The unit for the option value for socket option constants */
  27. int unit;
  28. };
  29. ----
  30. More structure members may be added in future, but the input pointer will be
  31. written only up to 'buflen' so the ABI is forward-compatible.
  32. Typically a client will iterate through the symbols until nn_symbol_info
  33. returns NULL in order to collect all the symbols.
  34. All symbols exposed by 'nn_symbol_info' are available directly in the C API,
  35. generally as preprocessor macros. Thus, this function is useful mostly for
  36. language bindings that can't parse the header file and rely on retrieving the
  37. symbols at runtime.
  38. Note that the NN_MSG symbol is not exported by the 'nn_symbol_info' function.
  39. First, it is a pointer rather than an integer; second, the symbol is not
  40. supposed to be exported from language bindings to the user. Instead, language
  41. bindings should provide the zero-copy functionality in a language-specific way,
  42. if at all (zero-copy functionality may not make sense for some
  43. languages/bindings).
  44. AVAILABLE NAMESPACES
  45. --------------------
  46. *NN_NS_NAMESPACE*::
  47. Equals to zero and denotes the NN_NS_* constants themselves
  48. *NN_NS_VERSION*::
  49. Nanomsg version constants
  50. *NN_NS_DOMAIN*::
  51. Socket domain (or address family) constants AF_SP, AF_SP_RAW
  52. *NN_NS_TRANSPORT*::
  53. Transport name constants (used for socket options mainly)
  54. *NN_NS_PROTOCOL*::
  55. Socket protocol constants
  56. *NN_NS_OPTION_LEVEL*::
  57. Socket option level constants (NN_SOL_SOCKET)
  58. *NN_NS_SOCKET_OPTION*::
  59. Socket options for NN_SOL_SOCKET level
  60. *NN_NS_TRANSPORT_OPTION*::
  61. Socket options for transport level (used with transport constants)
  62. *NN_NS_OPTION_TYPE*::
  63. The option types (described below)
  64. *NN_NS_FLAG*::
  65. The nn_send/nn_recv flags (only NN_DONTWAIT for now)
  66. *NN_NS_ERROR*::
  67. The errno values
  68. *NN_NS_LIMIT*::
  69. Various nanomsg limits (only NN_SOCKADDR_MAX for now)
  70. *NN_NS_EVENT*::
  71. Event flags (bit mask) for use with nn_poll (NN_POLLIN, NN_POLLOUT)
  72. AVAILABLE OPTION TYPES
  73. ----------------------
  74. *NN_TYPE_NONE*::
  75. No type, is returned for constants that are not socket options
  76. *NN_TYPE_INT*::
  77. The integer type
  78. *NN_TYPE_STR*::
  79. String (char *) type
  80. More types may be added in the future to nanomsg. You may enumerate all of them
  81. using the 'nn_symbol_info' itself by checking 'NN_NS_OPTION_TYPE' namespace.
  82. AVAILABLE OPTION UNITS
  83. ----------------------
  84. *NN_UNIT_NONE*::
  85. No unit, is returned for constants that are not socket options, or do not have
  86. any meaningful unit (strings, integer values)
  87. *NN_UNIT_BYTES*::
  88. The option value is expressed in bytes
  89. *NN_UNIT_MILLISECONDS*::
  90. The option value is expressed in milliseconds
  91. *NN_UNIT_PRIORITY*::
  92. The option value is a priority, an integer from 1 to 16
  93. *NN_UNIT_BOOLEAN*::
  94. The option value is boolean, an integer 0 or 1
  95. More types may be added in the future to nanomsg. You may enumerate all of them
  96. using the 'nn_symbol_info' itself by checking 'NN_NS_OPTION_TYPE' namespace.
  97. RETURN VALUE
  98. ------------
  99. If 'i' is valid, returns the number of bytes stored at the structure. The
  100. maximum value that can be returned is 'buflen'.
  101. If 'i' is out-of-range, nn_symbol_info returns zero.
  102. EXAMPLE
  103. -------
  104. ----
  105. int i;
  106. for (i = 0; ; ++i) {
  107. struct nn_symbol_properties sym;
  108. int rc = nn_symbol_info (i, &sym, sizeof (sym));
  109. if(rc == 0)
  110. break;
  111. assert (rc == sizeof (sym));
  112. printf ("'%s' = %d\n", sym.name, sym.value);
  113. }
  114. ----
  115. SEE ALSO
  116. --------
  117. <<nn_symbol#,nn_symbol(3)>>
  118. <<nn_errno#,nn_errno(3)>>
  119. <<nn_strerror#,nn_strerror(3)>>
  120. <<nanomsg#,nanomsg(7)>>
  121. AUTHORS
  122. -------
  123. link:mailto:paul@colomiets.name[Paul Colomiets]
  124. link:mailto:garrett@damore.org[Garrett D'Amore]