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

« back to all changes in this revision

Viewing changes to doc/zmq_recvmsg.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_recvmsg(3)
 
2
==============
 
3
 
 
4
 
 
5
NAME
 
6
----
 
7
zmq_recvmsg - receive a message part from a socket
 
8
 
 
9
 
 
10
SYNOPSIS
 
11
--------
 
12
*int zmq_recvmsg (void '*socket', zmq_msg_t '*msg', int 'flags');*
 
13
 
 
14
 
 
15
DESCRIPTION
 
16
-----------
 
17
The _zmq_recvmsg()_ function shall receive a message part from the socket
 
18
referenced by the 'socket' argument and store it in the message referenced by
 
19
the 'msg' argument. Any content previously stored in 'msg' shall be properly
 
20
deallocated. If there are no message parts available on the specified 'socket'
 
21
the _zmq_recvmsg()_ function shall block until the request can be satisfied.
 
22
The 'flags' argument is a combination of the flags defined below:
 
23
 
 
24
*ZMQ_DONTWAIT*::
 
25
Specifies that the operation should be performed in non-blocking mode. If there
 
26
are no messages available on the specified 'socket', the _zmq_recvmsg()_
 
27
function shall fail with 'errno' set to EAGAIN.
 
28
 
 
29
 
 
30
Multi-part messages
 
31
~~~~~~~~~~~~~~~~~~~
 
32
A 0MQ message is composed of 1 or more message parts. Each message
 
33
part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic
 
34
delivery of messages; peers shall receive either all _message parts_ of a
 
35
message or none at all. The total number of message parts is unlimited except
 
36
by available memory.
 
37
 
 
38
An application that processes multipart messages must use the _ZMQ_RCVMORE_
 
39
linkzmq:zmq_getsockopt[3] option after calling _zmq_recvmsg()_ to determine if
 
40
there are further parts to receive.
 
41
 
 
42
 
 
43
RETURN VALUE
 
44
------------
 
45
The _zmq_recvmsg()_ function shall return number of bytes in the message
 
46
if successful. Otherwise it shall return `-1` and set 'errno' to one of the
 
47
values defined below.
 
48
 
 
49
 
 
50
ERRORS
 
51
------
 
52
*EAGAIN*::
 
53
Non-blocking mode was requested and no messages are available at the moment.
 
54
*ENOTSUP*::
 
55
The _zmq_recvmsg()_ operation is not supported by this socket type.
 
56
*EFSM*::
 
57
The _zmq_recvmsg()_ operation cannot be performed on this socket at the moment
 
58
due to the socket not being in the appropriate state.  This error may occur with
 
59
socket types that switch between several states, such as ZMQ_REP.  See the
 
60
_messaging patterns_ section of linkzmq:zmq_socket[3] for more information.
 
61
*ETERM*::
 
62
The 0MQ 'context' associated with the specified 'socket' was terminated.
 
63
*ENOTSOCK*::
 
64
The provided 'socket' was invalid.
 
65
*EINTR*::
 
66
The operation was interrupted by delivery of a signal before a message was
 
67
available.
 
68
*EFAULT*::
 
69
The message passed to the function was invalid.
 
70
 
 
71
 
 
72
EXAMPLE
 
73
-------
 
74
.Receiving a message from a socket
 
75
----
 
76
/* Create an empty 0MQ message */
 
77
zmq_msg_t msg;
 
78
int rc = zmq_msg_init (&msg);
 
79
assert (rc == 0);
 
80
/* Block until a message is available to be received from socket */
 
81
rc = zmq_recvmsg (socket, &msg, 0);
 
82
assert (rc != -1);
 
83
/* Release message */
 
84
zmq_msg_close (&msg);
 
85
----
 
86
 
 
87
.Receiving a multi-part message
 
88
----
 
89
int64_t more;
 
90
size_t more_size = sizeof more;
 
91
do {
 
92
    /* Create an empty 0MQ message to hold the message part */
 
93
    zmq_msg_t part;
 
94
    int rc = zmq_msg_init (&part);
 
95
    assert (rc == 0);
 
96
    /* Block until a message is available to be received from socket */
 
97
    rc = zmq_recvmsg (socket, &part, 0);
 
98
    assert (rc != -1);
 
99
    /* Determine if more message parts are to follow */
 
100
    rc = zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
 
101
    assert (rc == 0);
 
102
    zmq_msg_close (&part);
 
103
} while (more);
 
104
----
 
105
 
 
106
 
 
107
SEE ALSO
 
108
--------
 
109
linkzmq:zmq_recv[3]
 
110
linkzmq:zmq_send[3]
 
111
linkzmq:zmq_sendmsg[3]
 
112
linkzmq:zmq_getsockopt[3]
 
113
linkzmq:zmq_socket[7]
 
114
linkzmq:zmq[7]
 
115
 
 
116
 
 
117
AUTHORS
 
118
-------
 
119
This man page was written by Martin Sustrik <sustrik@250bpm.com>, Martin
 
120
Lucina <martin@lucina.net> and Pieter Hintjens <ph@imatix.com>.
 
121