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

Function init_test_server

test/connect-rep.c:25–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23static unsigned long ud;
24
25static int init_test_server(struct sockaddr_in *serv_addr)
26{
27 socklen_t servaddr_len = sizeof(struct sockaddr_in);
28 int fd;
29
30 /* Init server socket. Bind but don't listen */
31 fd = socket(AF_INET, SOCK_STREAM, 0);
32 if (fd < 0) {
33 perror("socket");
34 return -1;
35 }
36
37 serv_addr->sin_family = AF_INET;
38 serv_addr->sin_addr.s_addr = inet_addr("127.0.0.1");
39
40 if (bind(fd, (struct sockaddr *) serv_addr, servaddr_len) < 0) {
41 perror("bind");
42 return -1;
43 }
44
45 /*
46 * Get the addresses the socket is bound to because the port is chosen
47 * by the network stack.
48 */
49 if (getsockname(fd, (struct sockaddr *)serv_addr, &servaddr_len) < 0) {
50 perror("getsockname");
51 return -1;
52 }
53
54 return fd;
55}
56
57static int init_test_client(void)
58{

Callers 1

testFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected