MCPcopy Create free account
hub / github.com/axboe/liburing / do_send

Function do_send

test/send_recv.c:192–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192static int do_send(int async, int vec, int big_vec)
193{
194 struct sockaddr_in saddr;
195 struct iovec vecs[32];
196 struct io_uring ring;
197 struct io_uring_cqe *cqe;
198 struct io_uring_sqe *sqe;
199 int sockfd, ret;
200
201 ret = io_uring_queue_init(1, &ring, 0);
202 if (ret) {
203 fprintf(stderr, "queue init failed: %d\n", ret);
204 return 1;
205 }
206
207 memset(&saddr, 0, sizeof(saddr));
208 saddr.sin_family = AF_INET;
209 saddr.sin_port = htons(PORT);
210 inet_pton(AF_INET, HOST, &saddr.sin_addr);
211
212 sockfd = socket(AF_INET, SOCK_DGRAM, 0);
213 if (sockfd < 0) {
214 perror("socket");
215 goto err2;
216 }
217
218 ret = connect(sockfd, (struct sockaddr *)&saddr, sizeof(saddr));
219 if (ret < 0) {
220 perror("connect");
221 goto err;
222 }
223
224retry:
225 sqe = io_uring_get_sqe(&ring);
226 if (vec) {
227 size_t total = MAX_MSG;
228 uint64_t *ptr = str;
229 int i, nvecs;
230
231 if (!big_vec) {
232 vecs[0].iov_base = str;
233 vecs[0].iov_len = MAX_MSG / 2;
234 vecs[1].iov_base = &str[256];
235 vecs[1].iov_len = MAX_MSG / 2;
236 nvecs = 2;
237 } else {
238 total /= 32;
239
240 for (i = 0; i < 32; i++) {
241 vecs[i].iov_base = ptr;
242 vecs[i].iov_len = total;
243 ptr += total / sizeof(uint64_t);
244 }
245 nvecs = 32;
246 }
247
248 io_uring_prep_send(sqe, sockfd, vecs, nvecs, 0);
249 sqe->ioprio = (1U << 5);

Callers 1

testFunction · 0.70

Calls 4

io_uring_queue_initFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_queue_exitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected