1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
'\" t
.\" Title: zmq_send
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 04/04/2012
.\" Manual: 0MQ Manual
.\" Source: 0MQ 2.2.0
.\" Language: English
.\"
.TH "ZMQ_SEND" "3" "04/04/2012" "0MQ 2\&.2\&.0" "0MQ Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
zmq_send \- send a message on a socket
.SH "SYNOPSIS"
.sp
\fBint zmq_send (void \fR\fB\fI*socket\fR\fR\fB, zmq_msg_t \fR\fB\fI*msg\fR\fR\fB, int \fR\fB\fIflags\fR\fR\fB);\fR
.SH "DESCRIPTION"
.sp
The \fIzmq_send()\fR function shall queue the message referenced by the \fImsg\fR argument to be sent to the socket referenced by the \fIsocket\fR argument\&. The \fIflags\fR argument is a combination of the flags defined below:
.PP
\fBZMQ_NOBLOCK\fR
.RS 4
Specifies that the operation should be performed in non\-blocking mode\&. If the message cannot be queued on the
\fIsocket\fR, the
\fIzmq_send()\fR
function shall fail with
\fIerrno\fR
set to EAGAIN\&.
.RE
.PP
\fBZMQ_SNDMORE\fR
.RS 4
Specifies that the message being sent is a multi\-part message, and that further message parts are to follow\&. Refer to the section regarding multi\-part messages below for a detailed description\&.
.RE
.sp
The \fIzmq_msg_t\fR structure passed to \fIzmq_send()\fR is nullified during the call\&. If you want to send the same message to multiple sockets you have to copy it using (e\&.g\&. using \fIzmq_msg_copy()\fR)\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
.sp
A successful invocation of \fIzmq_send()\fR does not indicate that the message has been transmitted to the network, only that it has been queued on the \fIsocket\fR and 0MQ has assumed responsibility for the message\&.
.sp .5v
.RE
.SS "Multi\-part messages"
.sp
A 0MQ message is composed of 1 or more message parts; each message part is an independent \fIzmq_msg_t\fR in its own right\&. 0MQ ensures atomic delivery of messages; peers shall receive either all \fImessage parts\fR of a message or none at all\&.
.sp
The total number of message parts is unlimited\&.
.sp
An application wishing to send a multi\-part message does so by specifying the \fIZMQ_SNDMORE\fR flag to \fIzmq_send()\fR\&. The presence of this flag indicates to 0MQ that the message being sent is a multi\-part message and that more message parts are to follow\&. When the application wishes to send the final message part it does so by calling \fIzmq_send()\fR without the \fIZMQ_SNDMORE\fR flag; this indicates that no more message parts are to follow\&.
.SH "RETURN VALUE"
.sp
The \fIzmq_send()\fR function shall return zero if successful\&. Otherwise it shall return \-1 and set \fIerrno\fR to one of the values defined below\&.
.SH "ERRORS"
.PP
\fBEAGAIN\fR
.RS 4
Non\-blocking mode was requested and the message cannot be sent at the moment\&.
.RE
.PP
\fBENOTSUP\fR
.RS 4
The
\fIzmq_send()\fR
operation is not supported by this socket type\&.
.RE
.PP
\fBEFSM\fR
.RS 4
The
\fIzmq_send()\fR
operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state\&. This error may occur with socket types that switch between several states, such as ZMQ_REP\&. See the
\fImessaging patterns\fR
section of
\fBzmq_socket\fR(3)
for more information\&.
.RE
.PP
\fBETERM\fR
.RS 4
The 0MQ
\fIcontext\fR
associated with the specified
\fIsocket\fR
was terminated\&.
.RE
.PP
\fBENOTSOCK\fR
.RS 4
The provided
\fIsocket\fR
was invalid\&.
.RE
.PP
\fBEINTR\fR
.RS 4
The operation was interrupted by delivery of a signal before the message was sent\&.
.RE
.PP
\fBEFAULT\fR
.RS 4
Invalid message\&.
.RE
.SH "EXAMPLE"
.PP
\fBFilling in a message and sending it to a socket\fR.
.sp
.if n \{\
.RS 4
.\}
.nf
/* Create a new message, allocating 6 bytes for message content */
zmq_msg_t msg;
int rc = zmq_msg_init_size (&msg, 6);
assert (rc == 0);
/* Fill in message content with \*(AqAAAAAA\*(Aq */
memset (zmq_msg_data (&msg), \*(AqA\*(Aq, 6);
/* Send the message to the socket */
rc = zmq_send (socket, &msg, 0);
assert (rc == 0);
.fi
.if n \{\
.RE
.\}
.PP
\fBSending a multi-part message\fR.
.sp
.if n \{\
.RS 4
.\}
.nf
/* Send a multi\-part message consisting of three parts to socket */
rc = zmq_send (socket, &part1, ZMQ_SNDMORE);
rc = zmq_send (socket, &part2, ZMQ_SNDMORE);
/* Final part; no more parts to follow */
rc = zmq_send (socket, &part3, 0);
.fi
.if n \{\
.RE
.\}
.sp
.SH "SEE ALSO"
.sp
\fBzmq_recv\fR(3) \fBzmq_socket\fR(7) \fBzmq\fR(7)
.SH "AUTHORS"
.sp
This manual page was written by the 0MQ community\&.
|