7
zmq_sendmsg - send a message part on a socket
12
*int zmq_sendmsg (void '*socket', zmq_msg_t '*msg', int 'flags');*
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:
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.
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.
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()_).
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.
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
48
An application that sends multipart messages must use the _ZMQ_SNDMORE_ flag
49
when sending each data part except the final one.
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
61
Non-blocking mode was requested and the message cannot be sent at the moment.
63
The _zmq_sendmsg()_ operation is not supported by this socket type.
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.
70
The 0MQ 'context' associated with the specified 'socket' was terminated.
72
The provided 'socket' was invalid.
74
The operation was interrupted by delivery of a signal before the message was
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.
85
.Filling in a message and sending it to a socket
87
/* Create a new message, allocating 6 bytes for message content */
89
int rc = zmq_msg_init_size (&msg, 6);
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);
98
.Sending a multi-part message
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);
112
linkzmq:zmq_recvmsg[3]
113
linkzmq:zmq_socket[7]
119
+This man page was written by Martin Sustrik <sustrik@250bpm.com>, Martin
120
+Lucina <martin@lucina.net> and Pieter Hintjens <ph@imatix.com>.