1ZMQ_SEND(3)                       0MQ Manual                       ZMQ_SEND(3)
2
3
4

NAME

6       zmq_send - send a message on a socket
7

SYNOPSIS

9       int zmq_send (void *socket, zmq_msg_t *msg, int flags);
10

DESCRIPTION

12       The zmq_send() function shall queue the message referenced by the msg
13       argument to be sent to the socket referenced by the socket argument.
14       The flags argument is a combination of the flags defined below:
15
16       ZMQ_NOBLOCK
17           Specifies that the operation should be performed in non-blocking
18           mode. If the message cannot be queued on the socket, the zmq_send()
19           function shall fail with errno set to EAGAIN.
20
21       ZMQ_SNDMORE
22           Specifies that the message being sent is a multi-part message, and
23           that further message parts are to follow. Refer to the section
24           regarding multi-part messages below for a detailed description.
25
26           Note
27           A successful invocation of zmq_send() does not indicate that the
28           message has been transmitted to the network, only that it has been
29           queued on the socket and 0MQ has assumed responsibility for the
30           message.
31
32   Multi-part messages
33       A 0MQ message is composed of 1 or more message parts; each message part
34       is an independent zmq_msg_t in its own right. 0MQ ensures atomic
35       delivery of messages; peers shall receive either all message parts of a
36       message or none at all.
37
38       The total number of message parts is unlimited.
39
40       An application wishing to send a multi-part message does so by
41       specifying the ZMQ_SNDMORE flag to zmq_send(). The presence of this
42       flag indicates to 0MQ that the message being sent is a multi-part
43       message and that more message parts are to follow. When the application
44       wishes to send the final message part it does so by calling zmq_send()
45       without the ZMQ_SNDMORE flag; this indicates that no more message parts
46       are to follow.
47

RETURN VALUE

49       The zmq_send() function shall return zero if successful. Otherwise it
50       shall return -1 and set errno to one of the values defined below.
51

ERRORS

53       EAGAIN
54           Non-blocking mode was requested and the message cannot be sent at
55           the moment.
56
57       ENOTSUP
58           The zmq_send() operation is not supported by this socket type.
59
60       EFSM
61           The zmq_send() operation cannot be performed on this socket at the
62           moment due to the socket not being in the appropriate state. This
63           error may occur with socket types that switch between several
64           states, such as ZMQ_REP. See the messaging patterns section of
65           zmq_socket(3) for more information.
66
67       ETERM
68           The 0MQ context associated with the specified socket was
69           terminated.
70
71       EFAULT
72           The provided socket was not valid (NULL).
73
74       EINTR
75           The operation was interrupted by delivery of a signal before the
76           message was sent.
77

EXAMPLE

79       Filling in a message and sending it to a socket.
80
81           /* Create a new message, allocating 6 bytes for message content */
82           zmq_msg_t msg;
83           int rc = zmq_msg_init_size (&msg, 6);
84           assert (rc == 0);
85           /* Fill in message content with 'AAAAAA' */
86           memset (zmq_msg_data (&msg), 'A', 6);
87           /* Send the message to the socket */
88           rc = zmq_send (socket, &msg, 0);
89           assert (rc == 0);
90
91       Sending a multi-part message.
92
93           /* Send a multi-part message consisting of three parts to socket */
94           rc = zmq_send (socket, &part1, ZMQ_SNDMORE);
95           rc = zmq_send (socket, &part2, ZMQ_SNDMORE);
96           /* Final part; no more parts to follow */
97           rc = zmq_send (socket, &part3, 0);
98
99

SEE ALSO

101       zmq_recv(3) zmq_socket(7) zmq(7)
102

AUTHORS

104       This 0MQ manual page was written by Martin Sustrik
105       <sustrik@250bpm.com[1]> and Martin Lucina <mato@kotelna.sk[2]>.
106

NOTES

108        1. sustrik@250bpm.com
109           mailto:sustrik@250bpm.com
110
111        2. mato@kotelna.sk
112           mailto:mato@kotelna.sk
113
114
115
1160MQ 2.1.4                         03/30/2011                       ZMQ_SEND(3)
Impressum