~ubuntu-branches/ubuntu/saucy/zeromq3/saucy

« back to all changes in this revision

Viewing changes to doc/zmq_msg_init_data.txt

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-06-04 21:21:09 UTC
  • Revision ID: package-import@ubuntu.com-20120604212109-b7b3m0rn21o8oo2q
Tags: upstream-3.1.0~beta+dfsg
ImportĀ upstreamĀ versionĀ 3.1.0~beta+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
zmq_msg_init_data(3)
 
2
====================
 
3
 
 
4
 
 
5
NAME
 
6
----
 
7
zmq_msg_init_data - initialise 0MQ message from a supplied buffer
 
8
 
 
9
 
 
10
SYNOPSIS
 
11
--------
 
12
*typedef void (zmq_free_fn) (void '*data', void '*hint');*
 
13
 
 
14
*int zmq_msg_init_data (zmq_msg_t '*msg', void '*data', size_t 'size', zmq_free_fn '*ffn', void '*hint');*
 
15
 
 
16
 
 
17
DESCRIPTION
 
18
-----------
 
19
The _zmq_msg_init_data()_ function shall initialise the message object
 
20
referenced by 'msg' to represent the content referenced by the buffer located
 
21
at address 'data', 'size' bytes long. No copy of 'data' shall be performed and
 
22
0MQ shall take ownership of the supplied buffer.
 
23
 
 
24
If provided, the deallocation function 'ffn' shall be called once the data
 
25
buffer is no longer required by 0MQ, with the 'data' and 'hint' arguments
 
26
supplied to _zmq_msg_init_data()_.
 
27
 
 
28
CAUTION: Never access 'zmq_msg_t' members directly, instead always use the
 
29
_zmq_msg_ family of functions.
 
30
 
 
31
CAUTION: The deallocation function 'ffn' needs to be thread-safe, since it
 
32
will be called from an arbitrary thread.
 
33
 
 
34
CAUTION: The functions _zmq_msg_init()_, _zmq_msg_init_data()_ and
 
35
_zmq_msg_init_size()_ are mutually exclusive. Never initialize the same
 
36
'zmq_msg_t' twice.
 
37
 
 
38
 
 
39
RETURN VALUE
 
40
------------
 
41
The _zmq_msg_init_data()_ function shall return zero if successful. Otherwise
 
42
it shall return `-1` and set 'errno' to one of the values defined below.
 
43
 
 
44
 
 
45
ERRORS
 
46
------
 
47
*ENOMEM*::
 
48
Insufficient storage space is available.
 
49
 
 
50
 
 
51
 
 
52
EXAMPLE
 
53
-------
 
54
.Initialising a message from a supplied buffer
 
55
----
 
56
void my_free (void *data, void *hint) 
 
57
{
 
58
    free (data);
 
59
}
 
60
 
 
61
    /*  ...  */
 
62
 
 
63
void *data = malloc (6);
 
64
assert (data);
 
65
memcpy (data, "ABCDEF", 6);
 
66
zmq_msg_t msg;
 
67
rc = zmq_msg_init_data (&msg, data, 6, my_free, NULL);
 
68
assert (rc == 0);
 
69
----
 
70
 
 
71
 
 
72
SEE ALSO
 
73
--------
 
74
linkzmq:zmq_msg_init_size[3]
 
75
linkzmq:zmq_msg_init[3]
 
76
linkzmq:zmq_msg_close[3]
 
77
linkzmq:zmq_msg_data[3]
 
78
linkzmq:zmq_msg_size[3]
 
79
linkzmq:zmq[7]
 
80
 
 
81
 
 
82
AUTHORS
 
83
-------
 
84
The 0MQ documentation was written by Martin Sustrik <sustrik@250bpm.com> and
 
85
Martin Lucina <martin@lucina.net>.