1ZMQ_SEND(3) 0MQ Manual ZMQ_SEND(3)
2
3
4
6 zmq_send - send a message part on a socket
7
9 int zmq_send (void *socket, const void *buf, size_t len, int flags);
10
12 The zmq_send() function shall queue a message created from the buffer
13 referenced by the buf and len arguments. The flags argument is a
14 combination of the flags defined below:
15
16 ZMQ_DONTWAIT
17 For socket types (DEALER, PUSH) that block (either with
18 ZMQ_IMMEDIATE option set and no peer available, or all peers having
19 full high-water mark), specifies that the operation should be
20 performed in non-blocking mode. If the message cannot be queued on
21 the socket, the zmq_send() function shall fail with errno set to
22 EAGAIN.
23
24 ZMQ_SNDMORE
25 Specifies that the message being sent is a multi-part message, and
26 that further message parts are to follow. Refer to the section
27 regarding multi-part messages below for a detailed description.
28
29 Note
30 A successful invocation of zmq_send() does not indicate that the
31 message has been transmitted to the network, only that it has been
32 queued on the socket and 0MQ has assumed responsibility for the
33 message.
34
35 Multi-part messages
36 A 0MQ message is composed of 1 or more message parts. 0MQ ensures
37 atomic delivery of messages: peers shall receive either all message
38 parts of a message or none at all. The total number of message parts is
39 unlimited except by available memory.
40
41 An application that sends multi-part messages must use the ZMQ_SNDMORE
42 flag when sending each message part except the final one.
43
45 The zmq_send() function shall return number of bytes in the message if
46 successful. Otherwise it shall return -1 and set errno to one of the
47 values defined below.
48
50 EAGAIN
51 Non-blocking mode was requested and the message cannot be sent at
52 the moment.
53
54 ENOTSUP
55 The zmq_send() operation is not supported by this socket type.
56
57 EINVAL
58 The sender tried to send multipart data, which the socket type does
59 not allow.
60
61 EFSM
62 The zmq_send() operation cannot be performed on this socket at the
63 moment due to the socket not being in the appropriate state. This
64 error may occur with socket types that switch between several
65 states, such as ZMQ_REP. See the messaging patterns section of
66 zmq_socket(3) for more information.
67
68 ETERM
69 The 0MQ context associated with the specified socket was
70 terminated.
71
72 ENOTSOCK
73 The provided socket was invalid.
74
75 EINTR
76 The operation was interrupted by delivery of a signal before the
77 message was sent.
78
79 EHOSTUNREACH
80 The message cannot be routed.
81
83 Sending a multi-part message.
84
85 /* Send a multi-part message consisting of three parts to socket */
86 rc = zmq_send (socket, "ABC", 3, ZMQ_SNDMORE);
87 assert (rc == 3);
88 rc = zmq_send (socket, "DEFGH", 5, ZMQ_SNDMORE);
89 assert (rc == 5);
90 /* Final part; no more parts to follow */
91 rc = zmq_send (socket, "JK", 2, 0);
92 assert (rc == 2);
93
94
96 zmq_send_const(3) zmq_recv(3) zmq_socket(7) zmq(7)
97
99 This page was written by the 0MQ community. To make a change please
100 read the 0MQ Contribution Policy at
101 http://www.zeromq.org/docs:contributing.
102
103
104
1050MQ 4.3.4 07/23/2022 ZMQ_SEND(3)