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

NAME

6       zmq_recv - receive a message part from a socket
7

SYNOPSIS

9       int zmq_recv (void *socket, void *buf, size_t len, int flags);
10

DESCRIPTION

12       The zmq_recv() function shall receive a message from the socket
13       referenced by the socket argument and store it in the buffer referenced
14       by the buf argument. Any bytes exceeding the length specified by the
15       len argument shall be truncated. If there are no messages available on
16       the specified socket the zmq_recv() function shall block until the
17       request can be satisfied. The flags argument is a combination of the
18       flags defined below: The buf argument may be null if len is zero.
19
20       ZMQ_DONTWAIT
21           Specifies that the operation should be performed in non-blocking
22           mode. If there are no messages available on the specified socket,
23           the zmq_recv() function shall fail with errno set to EAGAIN.
24
25   Multi-part messages
26       A 0MQ message is composed of 1 or more message parts. 0MQ ensures
27       atomic delivery of messages: peers shall receive either all message
28       parts of a message or none at all. The total number of message parts is
29       unlimited except by available memory.
30
31       An application that processes multi-part messages must use the
32       ZMQ_RCVMORE zmq_getsockopt(3) option after calling zmq_recv() to
33       determine if there are further parts to receive.
34

RETURN VALUE

36       The zmq_recv() function shall return number of bytes in the message if
37       successful. Note that the value can exceed the value of the len
38       parameter in case the message was truncated. If not successful the
39       function shall return -1 and set errno to one of the values defined
40       below.
41

ERRORS

43       EAGAIN
44           Either the timeout set via the socket-option ZMQ_RCVTIMEO (see
45           zmq_setsockopt(3)) has been reached (flag ZMQ_DONTWAIT not set)
46           without being able to read a message from the socket or there are
47           no messages available at the moment (flag ZMQ_DONTWAIT set) and the
48           operation would block.
49
50       ENOTSUP
51           The zmq_recv() operation is not supported by this socket type.
52
53       EFSM
54           The zmq_recv() operation cannot be performed on this socket at the
55           moment due to the socket not being in the appropriate state. This
56           error may occur with socket types that switch between several
57           states, such as ZMQ_REP. See the messaging patterns section of
58           zmq_socket(3) for more information.
59
60       ETERM
61           The 0MQ context associated with the specified socket was
62           terminated.
63
64       ENOTSOCK
65           The provided socket was invalid.
66
67       EINTR
68           The operation was interrupted by delivery of a signal before a
69           message was available.
70

EXAMPLE

72       Receiving a message from a socket.
73
74           char buf [256];
75           nbytes = zmq_recv (socket, buf, 256, 0);
76           assert (nbytes != -1);
77
78

SEE ALSO

80       zmq_send(3) zmq_getsockopt(3) zmq_setsockopt(3) zmq_socket(7) zmq(7)
81

AUTHORS

83       This page was written by the 0MQ community. To make a change please
84       read the 0MQ Contribution Policy at
85       http://www.zeromq.org/docs:contributing.
86
87
88
890MQ 4.3.4                         01/21/2023                       ZMQ_RECV(3)
Impressum