Lines Matching refs:fd
58 int fd, ret; in bind_port() local
60 fd = socket(AF_INET, SOCK_STREAM, 0); in bind_port()
61 ASSERT_NE(-1, fd) TH_LOG("failed to open socket."); in bind_port()
63 ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(int)); in bind_port()
66 ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &reuseport, sizeof(int)); in bind_port()
73 if (bind(fd, (struct sockaddr *)&local_addr, len) == -1) { in bind_port()
74 close(fd); in bind_port()
78 return fd; in bind_port()
84 int i, j, fd[2]; in TEST() local
90 fd[j] = bind_port(_metadata, opts->reuseaddr[j], opts->reuseport[j]); in TEST()
92 ASSERT_NE(-1, fd[0]) TH_LOG("failed to bind."); in TEST()
93 EXPECT_EQ(-1, fd[1]) TH_LOG("should fail to bind."); in TEST()
96 if (fd[j] != -1) in TEST()
97 close(fd[j]); in TEST()
104 int i, j, fd[2]; in TEST() local
110 fd[j] = bind_port(_metadata, opts->reuseaddr[j], opts->reuseport[j]); in TEST()
112 ASSERT_NE(-1, fd[0]) TH_LOG("failed to bind."); in TEST()
115 EXPECT_EQ(-1, fd[1]) TH_LOG("should fail to bind because both sockets succeed to be listened."); in TEST()
117 EXPECT_NE(-1, fd[1]) TH_LOG("should succeed to bind to connect to different destinations."); in TEST()
121 if (fd[j] != -1) in TEST()
122 close(fd[j]); in TEST()
129 int i, j, ret, fd[2]; in TEST() local
139 fd[j] = bind_port(_metadata, opts->reuseaddr[j], opts->reuseport[j]); in TEST()
145 ASSERT_NE(-1, fd[0]) TH_LOG("failed to bind."); in TEST()
146 …EXPECT_NE(-1, fd[1]) TH_LOG("should succeed to bind because one socket can be bound in each euid."… in TEST()
148 if (fd[1] != -1) { in TEST()
149 ret = listen(fd[0], 5); in TEST()
152 ret = listen(fd[1], 5); in TEST()
157 if (fd[j] != -1) in TEST()
158 close(fd[j]); in TEST()