zmq_msg_copy.txt 1.73 KB
Newer Older
1 2 3 4 5 6
zmq_msg_copy(3)
===============


NAME
----
Martin Lucina's avatar
Martin Lucina committed
7
zmq_msg_copy - copy content of a message to another message
8 9 10 11


SYNOPSIS
--------
Martin Lucina's avatar
Martin Lucina committed
12
*int zmq_msg_copy (zmq_msg_t '*dest', zmq_msg_t '*src');*
13 14 15 16


DESCRIPTION
-----------
Martin Lucina's avatar
Martin Lucina committed
17 18
The _zmq_msg_copy()_ function shall copy the message object referenced by 'src'
to the message object referenced by 'dest'. The original content of 'dest', if
19
any, shall be released. You must initialise 'dest' before copying to it.
20

Martin Lucina's avatar
Martin Lucina committed
21 22 23 24 25 26 27 28 29
CAUTION: The implementation may choose not to physically copy the message
content, rather to share the underlying buffer between 'src' and 'dest'. Avoid
modifying message content after a message has been copied with
_zmq_msg_copy()_, doing so can result in undefined behaviour. If what you need
is an actual hard copy, allocate a new message using _zmq_msg_init_size()_ and
copy the message content using _memcpy()_.

CAUTION: Never access 'zmq_msg_t' members directly, instead always use the
_zmq_msg_ family of functions.
30 31 32 33


RETURN VALUE
------------
Martin Lucina's avatar
Martin Lucina committed
34
The _zmq_msg_copy()_ function shall return zero if successful. Otherwise it
Martin Lucina's avatar
Martin Lucina committed
35
shall return `-1` and set 'errno' to one of the values defined below.
36 37 38 39


ERRORS
------
40 41
*EFAULT*::
Invalid message.
42 43


44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
EXAMPLE
-------
.Copying a message
----
zmq_msg_t msg;
zmq_msg_init_size (&msg, 255);
memcpy (zmq_msg_data (&msg, "Hello, World", 12);
zmq_msg_t copy;
zmq_msg_init (&copy);
zmq_msg_copy (&copy, &msg);
...
zmq_msg_close (&copy);
zmq_msg_close (&msg);
----

59 60 61 62 63 64 65
SEE ALSO
--------
linkzmq:zmq_msg_move[3]
linkzmq:zmq_msg_init[3]
linkzmq:zmq_msg_init_size[3]
linkzmq:zmq_msg_init_data[3]
linkzmq:zmq_msg_close[3]
Martin Lucina's avatar
Martin Lucina committed
66
linkzmq:zmq[7]
67 68


69 70
AUTHORS
-------
71 72
This page was written by the 0MQ community. To make a change please
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.