zmq_ctx_set_ext.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. zmq_ctx_set_ext(3)
  2. ==================
  3. NAME
  4. ----
  5. zmq_ctx_set_ext - set extended context options
  6. SYNOPSIS
  7. --------
  8. *int zmq_ctx_set_ext (void '*context', int 'option_name', const void '*option_value', size_t 'option_len');*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_ctx_set_ext()_ function shall set the option specified by the
  12. 'option_name' argument to the value pointed to by the 'option_value' argument
  13. for the 0MQ context pointed to by the 'context' argument. The 'option_len'
  14. argument is the size of the option value in bytes. For options taking a value of
  15. type "character string", the provided byte data should either contain no zero
  16. bytes, or end in a single zero byte (terminating ASCII NUL character).
  17. The _zmq_ctx_set_ext()_ function accepts all the option names accepted by
  18. _zmq_ctx_set()_.
  19. Options that make most sense to set using _zmq_ctx_set_ext()_ instead of
  20. _zmq_ctx_set()_ are the following options:
  21. ZMQ_THREAD_NAME_PREFIX: Set name prefix for I/O threads
  22. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. The 'ZMQ_THREAD_NAME_PREFIX' argument sets a string prefix to each thread
  24. created for the internal context's thread pool. This option is only supported on Linux.
  25. This option is useful to help debugging done via "top -H" or "gdb"; in case
  26. multiple processes on the system are using ZeroMQ it is useful to provide through
  27. this context option an application-specific prefix to distinguish ZeroMQ background
  28. threads that belong to different processes.
  29. This option only applies before creating any sockets on the context.
  30. [horizontal]
  31. Option value type:: character string
  32. Option value unit:: N/A
  33. Default value:: empty string
  34. RETURN VALUE
  35. ------------
  36. The _zmq_ctx_set_ext()_ function returns zero if successful. Otherwise it
  37. returns `-1` and sets 'errno' to one of the values defined below.
  38. ERRORS
  39. ------
  40. *EINVAL*::
  41. The requested option _option_name_ is unknown.
  42. EXAMPLE
  43. -------
  44. .Setting a prefix on internal ZMQ threda names:
  45. ----
  46. void *context = zmq_ctx_new ();
  47. const char prefix[] = "MyApp";
  48. size_t prefixLen = sizeof(prefix);
  49. zmq_ctx_set (context, ZMQ_THREAD_NAME_PREFIX, &prefix, &prefixLen);
  50. char buff[256];
  51. size_t buffLen = sizeof(buff);
  52. int rc = zmq_ctx_get (context, ZMQ_THREAD_NAME_PREFIX, &buff, &buffLen);
  53. assert (rc == 0);
  54. assert (buffLen == prefixLen);
  55. ----
  56. SEE ALSO
  57. --------
  58. linkzmq:zmq_ctx_set[3]
  59. linkzmq:zmq[7]
  60. AUTHORS
  61. -------
  62. This page was written by the 0MQ community. To make a change please
  63. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.