MCPcopy Create free account
hub / github.com/esnet/iperf / iperf_accept

Function iperf_accept

src/iperf_server_api.c:152–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152int
153iperf_accept(struct iperf_test *test)
154{
155 int s;
156 int ret = -1;
157 signed char rbuf = ACCESS_DENIED;
158 socklen_t len;
159 struct sockaddr_storage addr;
160
161 len = sizeof(addr);
162 if ((s = accept(test->listener, (struct sockaddr *) &addr, &len)) < 0) {
163 i_errno = IEACCEPT;
164 return ret;
165 }
166
167 if (test->ctrl_sck == -1) {
168 /* Server free, accept new client */
169 test->ctrl_sck = s;
170 // set TCP_NODELAY for lower latency on control messages
171 int flag = 1;
172 if (setsockopt(test->ctrl_sck, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int))) {
173 i_errno = IESETNODELAY;
174 goto error_handling;
175 }
176
177#if defined(HAVE_TCP_USER_TIMEOUT)
178 int opt;
179 if ((opt = test->settings->snd_timeout)) {
180 if (setsockopt(s, IPPROTO_TCP, TCP_USER_TIMEOUT, &opt, sizeof(opt)) < 0) {
181 i_errno = IESETUSERTIMEOUT;
182 goto error_handling;
183 }
184 }
185#endif /* HAVE_TCP_USER_TIMEOUT */
186
187#if defined (HAVE_TCP_KEEPALIVE)
188 // Set Control Connection TCP Keepalive (especially useful for long UDP test sessions)
189 if (iperf_set_control_keepalive(test) < 0)
190 return -1;
191#endif //HAVE_TCP_KEEPALIVE
192
193 if (Nread(test->ctrl_sck, test->cookie, COOKIE_SIZE, Ptcp) != COOKIE_SIZE) {
194 /*
195 * Note this error covers both the case of a system error
196 * or the inability to read the correct amount of data
197 * (i.e. timed out).
198 */
199 i_errno = IERECVCOOKIE;
200 goto error_handling;
201 }
202 FD_SET(test->ctrl_sck, &test->read_set);
203 if (test->ctrl_sck > test->max_fd) test->max_fd = test->ctrl_sck;
204
205 if (iperf_set_send_state(test, PARAM_EXCHANGE) != 0)
206 goto error_handling;
207 if (iperf_exchange_parameters(test) < 0)
208 goto error_handling;
209 if (test->server_affinity != -1) {

Callers 1

iperf_run_serverFunction · 0.85

Calls 6

NreadFunction · 0.85
iperf_set_send_stateFunction · 0.85
iperf_setaffinityFunction · 0.85
NwriteFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…