1io_uring_prep_recvmsg(3) liburing Manual io_uring_prep_recvmsg(3)
2
3
4
6 io_uring_prep_recvmsg - prepare a recvmsg request
7
9 #include <sys/types.h>
10 #include <sys/socket.h>
11 #include <liburing.h>
12
13 void io_uring_prep_recvmsg(struct io_uring_sqe *sqe,
14 int fd,
15 struct msghdr *msg,
16 unsigned flags);
17
18 void io_uring_prep_recvmsg_multishot(struct io_uring_sqe *sqe,
19 int fd,
20 struct msghdr *msg,
21 unsigned flags);
22
24 The io_uring_prep_recvmsg(3) function prepares a recvmsg request. The
25 submission queue entry sqe is setup to use the file descriptor fd to
26 start receiving the data indicated by msg with the recvmsg(2) defined
27 flags in the flags argument.
28
29 This function prepares an async recvmsg(2) request. See that man page
30 for details on the arguments specified to this prep helper.
31
32 The multishot version allows the application to issue a single receive
33 request, which repeatedly posts a CQE when data is available. It re‐
34 quires the IOSQE_BUFFER_SELECT flag to be set and no MSG_WAITALL flag
35 to be set. Therefore each CQE will take a buffer out of a provided
36 buffer pool for receiving. The application should check the flags of
37 each CQE, regardless of its result. If a posted CQE does not have the
38 IORING_CQE_F_MORE flag set then the multishot receive will be done and
39 the application should issue a new request.
40
41 Unlike recvmsg(2), multishot recvmsg will prepend a struct io_ur‐
42 ing_recvmsg_out which describes the layout of the rest of the buffer in
43 combination with the initial struct msghdr submitted with the request.
44 See io_uring_recvmsg_out(3) for more information on accessing the data.
45
46 Multishot variants are available since kernel 6.0.
47
48 After calling this function, additional io_uring internal modifier
49 flags may be set in the SQE ioprio field. The following flags are sup‐
50 ported:
51
52 IORING_RECVSEND_POLL_FIRST
53 If set, io_uring will assume the socket is currently empty and
54 attempting to receive data will be unsuccessful. For this case,
55 io_uring will arm internal poll and trigger a receive of the
56 data when the socket has data to be read. This initial receive
57 attempt can be wasteful for the case where the socket is ex‐
58 pected to be empty, setting this flag will bypass the initial
59 receive attempt and go straight to arming poll. If poll does in‐
60 dicate that data is ready to be received, the operation will
61 proceed.
62
63 Can be used with the CQE IORING_CQE_F_SOCK_NONEMPTY flag, which
64 io_uring will set on CQEs after a recv(2) or recvmsg(2) opera‐
65 tion. If set, the socket still had data to be read after the op‐
66 eration completed. Both these flags are available since 5.19.
67
69 None
70
72 The CQE res field will contain the result of the operation. See the re‐
73 lated man page for details on possible values. Note that where synchro‐
74 nous system calls will return -1 on failure and set errno to the actual
75 error value, io_uring never uses errno. Instead it returns the negated
76 errno directly in the CQE res field.
77
79 As with any request that passes in data in a struct, that data must re‐
80 main valid until the request has been successfully submitted. It need
81 not remain valid until completion. Once a request has been submitted,
82 the in-kernel state is stable. Very early kernels (5.4 and earlier) re‐
83 quired state to be stable until the completion occurred. Applications
84 can test for this behavior by inspecting the IORING_FEAT_SUBMIT_STABLE
85 flag passed back from io_uring_queue_init_params(3).
86
88 io_uring_get_sqe(3), io_uring_submit(3), recvmsg(2)
89
90
91
92liburing-2.2 March 12, 2022 io_uring_prep_recvmsg(3)