1
1

Merge pull request #222 from hasso/timeout-udp

Timeout if UDP port isn't reachable.

This handles the case that a control connection succeeds but UDP packets are blocked by a firewall.
Этот коммит содержится в:
Bruce A. Mah 2014-12-23 10:39:11 -08:00
родитель dba611dbe4 b83791882d
Коммит d275f166c8

Просмотреть файл

@ -300,6 +300,9 @@ int
iperf_udp_connect(struct iperf_test *test)
{
int s, buf, sz;
#ifdef SO_RCVTIMEO
struct timeval tv;
#endif
/* Create and bind our local socket. */
if ((s = netdial(test->settings->domain, Pudp, test->bind_address, test->bind_port, test->server_hostname, test->server_port)) < 0) {
@ -323,6 +326,13 @@ iperf_udp_connect(struct iperf_test *test)
}
}
#ifdef SO_RCVTIMEO
/* 30 sec timeout for a case when there is a network problem. */
tv.tv_sec = 30;
tv.tv_usec = 0;
setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)&tv, sizeof(struct timeval));
#endif
/*
* Write a datagram to the UDP stream to let the server know we're here.
* The server learns our address by obtaining its peer's address.