zmq_msg_copy.txt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. zmq_msg_copy(3)
  2. ===============
  3. NAME
  4. ----
  5. zmq_msg_copy - copy content of a message to another message
  6. SYNOPSIS
  7. --------
  8. *int zmq_msg_copy (zmq_msg_t '*dest', zmq_msg_t '*src');*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_msg_copy()_ function shall copy the message object referenced by 'src'
  12. to the message object referenced by 'dest'. The original content of 'dest', if
  13. any, shall be released. You must initialise 'dest' before copying to it.
  14. CAUTION: The implementation may choose not to physically copy the message
  15. content, rather to share the underlying buffer between 'src' and 'dest'. Avoid
  16. modifying message content after a message has been copied with
  17. _zmq_msg_copy()_, doing so can result in undefined behaviour. If what you need
  18. is an actual hard copy, initialize a new message using _zmq_msg_init_buffer()_
  19. with the message content.
  20. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the
  21. _zmq_msg_ family of functions.
  22. RETURN VALUE
  23. ------------
  24. The _zmq_msg_copy()_ function shall return zero if successful. Otherwise it
  25. shall return `-1` and set 'errno' to one of the values defined below.
  26. ERRORS
  27. ------
  28. *EFAULT*::
  29. Invalid message.
  30. EXAMPLE
  31. -------
  32. .Copying a message
  33. ----
  34. zmq_msg_t msg;
  35. zmq_msg_init_buffer (&msg, "Hello, World", 12);
  36. zmq_msg_t copy;
  37. zmq_msg_init (&copy);
  38. zmq_msg_copy (&copy, &msg);
  39. ...
  40. zmq_msg_close (&copy);
  41. zmq_msg_close (&msg);
  42. ----
  43. SEE ALSO
  44. --------
  45. linkzmq:zmq_msg_move[3]
  46. linkzmq:zmq_msg_init[3]
  47. linkzmq:zmq_msg_init_size[3]
  48. linkzmq:zmq_msg_init_buffer[3]
  49. linkzmq:zmq_msg_init_data[3]
  50. linkzmq:zmq_msg_close[3]
  51. linkzmq:zmq[7]
  52. AUTHORS
  53. -------
  54. This page was written by the 0MQ community. To make a change please
  55. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.