1io_uring_prep_recvmsg(3)        liburing Manual       io_uring_prep_recvmsg(3)
2
3
4

NAME

6       io_uring_prep_recvmsg - prepare a recvmsg request
7

SYNOPSIS

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

DESCRIPTION

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 it's 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
45       data.
46
47       Multishot variants are available since kernel 6.0.
48
49       After calling this  function,  additional  io_uring  internal  modifier
50       flags  may be set in the SQE ioprio field. The following flags are sup‐
51       ported:
52
53       IORING_RECVSEND_POLL_FIRST
54              If set, io_uring will assume the socket is currently  empty  and
55              attempting  to receive data will be unsuccessful. For this case,
56              io_uring will arm internal poll and trigger  a  receive  of  the
57              data  when the socket has data to be read.  This initial receive
58              attempt can be wasteful for the case where  the  socket  is  ex‐
59              pected  to  be  empty, setting this flag will bypass the initial
60              receive attempt and go straight to arming poll. If poll does in‐
61              dicate  that  data  is  ready to be received, the operation will
62              proceed.
63
64              Can be used with the CQE IORING_CQE_F_SOCK_NONEMPTY flag,  which
65              io_uring  will  set on CQEs after a recv(2) or recvmsg(2) opera‐
66              tion. If set, the socket still had data to be read after the op‐
67              eration completed. Both these flags are available since 5.19.
68

RETURN VALUE

70       None
71

ERRORS

73       The CQE res field will contain the result of the operation. See the re‐
74       lated man page for details on possible values. Note that where synchro‐
75       nous system calls will return -1 on failure and set errno to the actual
76       error value, io_uring never uses errno.  Instead it returns the negated
77       errno directly in the CQE res field.
78

NOTES

80       As with any request that passes in data in a struct, that data must re‐
81       main valid until the request has been successfully submitted.  It  need
82       not  remain  valid until completion. Once a request has been submitted,
83       the in-kernel state is stable. Very early kernels (5.4 and earlier) re‐
84       quired  state  to be stable until the completion occurred. Applications
85       can test for this behavior by inspecting the  IORING_FEAT_SUBMIT_STABLE
86       flag passed back from io_uring_queue_init_params(3).
87

SEE ALSO

89       io_uring_get_sqe(3), io_uring_submit(3), recvmsg(2)
90
91
92
93liburing-2.2                    March 12, 2022        io_uring_prep_recvmsg(3)
Impressum