zmq_msg_gets.txt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. zmq_msg_gets(3)
  2. ===============
  3. NAME
  4. ----
  5. zmq_msg_gets - get message metadata property
  6. SYNOPSIS
  7. --------
  8. *const char *zmq_msg_gets (zmq_msg_t '*message', const char *'property');*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_msg_gets()_ function shall return the string value for the metadata
  12. property specified by the 'property' argument for the message pointed to by
  13. the 'message' argument. Both the 'property' argument and the 'value'
  14. shall be NULL-terminated UTF8-encoded strings.
  15. Metadata is defined on a per-connection basis during the ZeroMQ connection
  16. handshake as specified in <rfc.zeromq.org/spec:37>. Applications can set
  17. metadata properties using linkzmq:zmq_setsockopt[3] option ZMQ_METADATA.
  18. Application metadata properties must be prefixed with 'X-'.
  19. In addition to application metadata, the following ZMTP properties can be
  20. retrieved with the _zmq_msg_gets()_ function:
  21. Socket-Type
  22. Routing-Id
  23. Note: 'Identity' is a deprecated alias for 'Routing-Id'.
  24. Additionally, when available for the underlying transport, the *Peer-Address*
  25. property will return the IP address of the remote endpoint as returned by
  26. getnameinfo(2).
  27. The names of these properties are also defined in _zmq.h_ as
  28. _ZMQ_MSG_PROPERTY_SOCKET_TYPE_ _ZMQ_MSG_PROPERTY_ROUTING_ID_, and
  29. _ZMQ_MSG_PROPERTY_PEER_ADDRESS_.
  30. Currently, these definitions are only available as a DRAFT API.
  31. Other properties may be defined based on the underlying security mechanism,
  32. see ZAP authenticated connection sample below.
  33. RETURN VALUE
  34. ------------
  35. The _zmq_msg_gets()_ function shall return the string value for the property
  36. if successful. Otherwise it shall return NULL and set 'errno' to one of the
  37. values defined below. The caller shall not modify or free the returned value,
  38. which shall be owned by the message. The encoding of the property and value
  39. shall be UTF8.
  40. ERRORS
  41. ------
  42. *EINVAL*::
  43. The requested _property_ is unknown.
  44. EXAMPLE
  45. -------
  46. .Getting the ZAP authenticated user id for a message:
  47. ----
  48. zmq_msg_t msg;
  49. zmq_msg_init (&msg);
  50. rc = zmq_msg_recv (&msg, dealer, 0);
  51. assert (rc != -1);
  52. const char *user_id = zmq_msg_gets (&msg, ZMQ_MSG_PROPERTY_USER_ID);
  53. zmq_msg_close (&msg);
  54. ----
  55. SEE ALSO
  56. --------
  57. linkzmq:zmq[7]
  58. linkzmq:zmq_setsockopt[3]
  59. AUTHORS
  60. -------
  61. This page was written by the 0MQ community. To make a change please
  62. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.