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

« back to all changes in this revision

Viewing changes to doc/zmq_sendmsg.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_sendmsg(3)
 
2
==============
 
3
 
 
4
 
 
5
NAME
 
6
----
 
7
zmq_sendmsg - send a message part on a socket
 
8
 
 
9
 
 
10
SYNOPSIS
 
11
--------
 
12
*int zmq_sendmsg (void '*socket', zmq_msg_t '*msg', int 'flags');*
 
13
 
 
14
 
 
15
DESCRIPTION
 
16
-----------
 
17
The _zmq_sendmsg()_ function shall queue the message referenced by the 'msg'
 
18
argument to be sent to the socket referenced by the 'socket' argument.  The
 
19
'flags' argument is a combination of the flags defined below:
 
20
 
 
21
*ZMQ_DONTWAIT*::
 
22
Specifies that the operation should be performed in non-blocking mode. If the
 
23
message cannot be queued on the 'socket', the _zmq_sendmsg()_ function shall
 
24
fail with 'errno' set to EAGAIN.
 
25
 
 
26
*ZMQ_SNDMORE*::
 
27
Specifies that the message being sent is a multi-part message, and that further
 
28
message parts are to follow. Refer to the section regarding multi-part messages
 
29
below for a detailed description.
 
30
 
 
31
The _zmq_msg_t_ structure passed to _zmq_sendmsg()_ is nullified during the
 
32
call. If you want to send the same message to multiple sockets you have to copy
 
33
it using (e.g. using _zmq_msg_copy()_).
 
34
 
 
35
NOTE: A successful invocation of _zmq_sendmsg()_ does not indicate that the
 
36
message has been transmitted to the network, only that it has been queued on
 
37
the 'socket' and 0MQ has assumed responsibility for the message.
 
38
 
 
39
 
 
40
Multi-part messages
 
41
~~~~~~~~~~~~~~~~~~~
 
42
A 0MQ message is composed of 1 or more message parts. Each message
 
43
part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic
 
44
delivery of messages; peers shall receive either all _message parts_ of a
 
45
message or none at all. The total number of message parts is unlimited except
 
46
by available memory.
 
47
 
 
48
An application that sends multipart messages must use the _ZMQ_SNDMORE_ flag
 
49
when sending each data part except the final one.
 
50
 
 
51
RETURN VALUE
 
52
------------
 
53
The _zmq_sendmsg()_ function shall return number of bytes in the message
 
54
if successful. Otherwise it shall return `-1` and set 'errno' to one of the
 
55
values defined below.
 
56
 
 
57
 
 
58
ERRORS
 
59
------
 
60
*EAGAIN*::
 
61
Non-blocking mode was requested and the message cannot be sent at the moment.
 
62
*ENOTSUP*::
 
63
The _zmq_sendmsg()_ operation is not supported by this socket type.
 
64
*EFSM*::
 
65
The _zmq_sendmsg()_ operation cannot be performed on this socket at the moment
 
66
due to the socket not being in the appropriate state.  This error may occur with
 
67
socket types that switch between several states, such as ZMQ_REP.  See the
 
68
_messaging patterns_ section of linkzmq:zmq_socket[3] for more information.
 
69
*ETERM*::
 
70
The 0MQ 'context' associated with the specified 'socket' was terminated.
 
71
*ENOTSOCK*::
 
72
The provided 'socket' was invalid.
 
73
*EINTR*::
 
74
The operation was interrupted by delivery of a signal before the message was
 
75
sent.
 
76
*EFAULT*::
 
77
Invalid message.
 
78
*ECANTROUTE*::
 
79
Message cannot be routed to the destination specified as the peer is either
 
80
dead or disconnected. This error makes sense only with ZMQ_ROUTER socket.
 
81
 
 
82
 
 
83
EXAMPLE
 
84
-------
 
85
.Filling in a message and sending it to a socket
 
86
----
 
87
/* Create a new message, allocating 6 bytes for message content */
 
88
zmq_msg_t msg;
 
89
int rc = zmq_msg_init_size (&msg, 6);
 
90
assert (rc == 0);
 
91
/* Fill in message content with 'AAAAAA' */
 
92
memset (zmq_msg_data (&msg), 'A', 6);
 
93
/* Send the message to the socket */
 
94
rc = zmq_sendmsg (socket, &msg, 0);
 
95
assert (rc == 6);
 
96
----
 
97
 
 
98
.Sending a multi-part message
 
99
----
 
100
/* Send a multi-part message consisting of three parts to socket */
 
101
rc = zmq_sendmsg (socket, &part1, ZMQ_SNDMORE);
 
102
rc = zmq_sendmsg (socket, &part2, ZMQ_SNDMORE);
 
103
/* Final part; no more parts to follow */
 
104
rc = zmq_sendmsg (socket, &part3, 0);
 
105
----
 
106
 
 
107
 
 
108
SEE ALSO
 
109
--------
 
110
linkzmq:zmq_recv[3]
 
111
linkzmq:zmq_recv[3]
 
112
linkzmq:zmq_recvmsg[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