zmq_msg_get.txt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. zmq_msg_get(3)
  2. ==============
  3. NAME
  4. ----
  5. zmq_msg_get - get message property
  6. SYNOPSIS
  7. --------
  8. *int zmq_msg_get (zmq_msg_t '*message', int 'property');*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_msg_get()_ function shall return the value for the property
  12. specified by the 'property' argument for the message pointed to by the
  13. 'message' argument.
  14. The following properties can be retrieved with the _zmq_msg_get()_ function:
  15. *ZMQ_MORE*::
  16. Indicates that there are more message frames to follow after the 'message'.
  17. *ZMQ_SRCFD*::
  18. Returns the file descriptor of the socket the 'message' was read from. This
  19. allows application to retrieve the remote endpoint via 'getpeername(2)'. Be
  20. aware that the respective socket might be closed already, reused even.
  21. Currently only implemented for TCP sockets.
  22. *ZMQ_SHARED*::
  23. Indicates that a message MAY share underlying storage with another copy of
  24. this message.
  25. RETURN VALUE
  26. ------------
  27. The _zmq_msg_get()_ function shall return the value for the property if
  28. successful. Otherwise it shall return `-1` and set 'errno' to one of the
  29. values defined below.
  30. ERRORS
  31. ------
  32. *EINVAL*::
  33. The requested _property_ is unknown.
  34. EXAMPLE
  35. -------
  36. .Receiving a multi-frame message
  37. ----
  38. zmq_msg_t frame;
  39. while (true) {
  40. // Create an empty 0MQ message to hold the message frame
  41. int rc = zmq_msg_init (&frame);
  42. assert (rc == 0);
  43. // Block until a message is available to be received from socket
  44. rc = zmq_msg_recv (socket, &frame, 0);
  45. assert (rc != -1);
  46. if (zmq_msg_get (&frame, ZMQ_MORE))
  47. fprintf (stderr, "more\n");
  48. else {
  49. fprintf (stderr, "end\n");
  50. break;
  51. }
  52. zmq_msg_close (&frame);
  53. }
  54. ----
  55. SEE ALSO
  56. --------
  57. linkzmq:zmq_msg_set[3]
  58. linkzmq:zmq_msg_init[3]
  59. linkzmq:zmq_msg_close[3]
  60. linkzmq:zmq[7]
  61. AUTHORS
  62. -------
  63. This page was written by the 0MQ community. To make a change please
  64. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.