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

Function init_test_client

test/connect-rep.c:57–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57static int init_test_client(void)
58{
59 socklen_t addr_len = sizeof(struct sockaddr_in);
60 struct sockaddr_in client_addr = {};
61 int clientfd;
62
63 clientfd = socket(AF_INET, SOCK_STREAM, 0);
64 if (clientfd < 0) {
65 perror("socket");
66 return -1;
67 }
68
69 client_addr.sin_family = AF_INET;
70 client_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
71
72 if (bind(clientfd, (struct sockaddr *)&client_addr, addr_len) < 0) {
73 perror("bind");
74 close(clientfd);
75 return -1;
76 }
77
78 /*
79 * Get the addresses the socket is bound to because the port is chosen
80 * by the network stack.
81 */
82 if (getsockname(clientfd, (struct sockaddr *)&client_addr, &addr_len) < 0) {
83 perror("getsockname");
84 close(clientfd);
85 return -1;
86 }
87
88 return clientfd;
89}
90
91static int get_completion_and_print(struct io_uring *ring)
92{

Callers 1

testFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected