zmq_send_const.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. zmq_send_const(3)
  2. =================
  3. NAME
  4. ----
  5. zmq_send_const - send a constant-memory message part on a socket
  6. SYNOPSIS
  7. --------
  8. *int zmq_send_const (void '*socket', const void '*buf', size_t 'len', int 'flags');*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_send_const()_ function shall queue a message created from the buffer
  12. referenced by the 'buf' and 'len' arguments. The message buffer is assumed
  13. to be constant-memory and will therefore not be copied or deallocated
  14. in any way. The 'flags' argument is a combination of the flags defined below:
  15. *ZMQ_DONTWAIT*::
  16. For socket types (DEALER, PUSH) that block (either with ZMQ_IMMEDIATE option set
  17. and no peer available, or all peers having full high-water mark), specifies that
  18. the operation should be performed in non-blocking mode. If the message cannot be
  19. queued on the 'socket', the _zmq_send_const()_ function shall fail with 'errno' set
  20. to EAGAIN.
  21. *ZMQ_SNDMORE*::
  22. Specifies that the message being sent is a multi-part message, and that further
  23. message parts are to follow. Refer to the section regarding multi-part messages
  24. below for a detailed description.
  25. NOTE: A successful invocation of _zmq_send_const()_ does not indicate that the
  26. message has been transmitted to the network, only that it has been queued on
  27. the 'socket' and 0MQ has assumed responsibility for the message.
  28. Multi-part messages
  29. ~~~~~~~~~~~~~~~~~~~
  30. A 0MQ message is composed of 1 or more message parts. 0MQ ensures atomic
  31. delivery of messages: peers shall receive either all _message parts_ of a
  32. message or none at all. The total number of message parts is unlimited except
  33. by available memory.
  34. An application that sends multi-part messages must use the _ZMQ_SNDMORE_ flag
  35. when sending each message part except the final one.
  36. RETURN VALUE
  37. ------------
  38. The _zmq_send_const()_ function shall return number of bytes in the message
  39. if successful. Otherwise it shall return `-1` and set 'errno' to one of the
  40. values defined below.
  41. ERRORS
  42. ------
  43. *EAGAIN*::
  44. Non-blocking mode was requested and the message cannot be sent at the moment.
  45. *ENOTSUP*::
  46. The _zmq_send_const()_ operation is not supported by this socket type.
  47. *EFSM*::
  48. The _zmq_send_const()_ operation cannot be performed on this socket at the moment
  49. due to the socket not being in the appropriate state. This error may occur with
  50. socket types that switch between several states, such as ZMQ_REP. See the
  51. _messaging patterns_ section of linkzmq:zmq_socket[3] for more information.
  52. *ETERM*::
  53. The 0MQ 'context' associated with the specified 'socket' was terminated.
  54. *ENOTSOCK*::
  55. The provided 'socket' was invalid.
  56. *EINTR*::
  57. The operation was interrupted by delivery of a signal before the message was
  58. sent.
  59. *EHOSTUNREACH*::
  60. The message cannot be routed.
  61. EXAMPLE
  62. -------
  63. .Sending a multi-part message
  64. ----
  65. /* Send a multi-part message consisting of three parts to socket */
  66. rc = zmq_send_const (socket, "ABC", 3, ZMQ_SNDMORE);
  67. assert (rc == 3);
  68. rc = zmq_send_const (socket, "DEFGH", 5, ZMQ_SNDMORE);
  69. assert (rc == 5);
  70. /* Final part; no more parts to follow */
  71. rc = zmq_send_const (socket, "JK", 2, 0);
  72. assert (rc == 2);
  73. ----
  74. SEE ALSO
  75. --------
  76. linkzmq:zmq_send[3]
  77. linkzmq:zmq_recv[3]
  78. linkzmq:zmq_socket[7]
  79. linkzmq:zmq[7]
  80. AUTHORS
  81. -------
  82. This page was written by the 0MQ community. To make a change please
  83. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.