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

Function main

test/socket-rw-offset.c:25–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#include "helpers.h"
24
25int main(int argc, char *argv[])
26{
27 int p_fd[2], ret;
28 int32_t recv_s0;
29 int32_t val = 1;
30 struct sockaddr_in addr;
31 struct iovec iov_r[1], iov_w[1];
32
33 if (argc > 1)
34 return 0;
35
36 srand(getpid());
37
38 recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
39
40 ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
41 assert(ret != -1);
42 ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
43 assert(ret != -1);
44
45 addr.sin_family = AF_INET;
46 addr.sin_addr.s_addr = inet_addr("127.0.0.1");
47 ret = t_bind_ephemeral_port(recv_s0, &addr);
48 assert(!ret);
49 ret = listen(recv_s0, 128);
50 assert(ret != -1);
51
52
53 p_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
54
55 val = 1;
56 ret = setsockopt(p_fd[1], IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
57 assert(ret != -1);
58
59 t_set_nonblock(p_fd[1]);
60
61 ret = connect(p_fd[1], (struct sockaddr*)&addr, sizeof(addr));
62 assert(ret == -1);
63
64 t_clear_nonblock(p_fd[1]);
65
66 p_fd[0] = accept(recv_s0, NULL, NULL);
67 assert(p_fd[0] != -1);
68
69 while (1) {
70 int32_t code;
71 socklen_t code_len = sizeof(code);
72
73 ret = getsockopt(p_fd[1], SOL_SOCKET, SO_ERROR, &code, &code_len);
74 assert(ret != -1);
75
76 if (!code)
77 break;
78 }
79
80 struct io_uring m_io_uring;
81 struct io_uring_params p = { };
82

Callers

nothing calls this directly

Calls 7

t_bind_ephemeral_portFunction · 0.85
t_set_nonblockFunction · 0.85
t_clear_nonblockFunction · 0.85
io_uring_submit_and_waitFunction · 0.85
io_uring_queue_exitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected