How can I stop iperf server when it finishes?
I think it depends on the version. I can speak for iperf 2 where we recently added this capability. When the -server
is launched there will ultimately be two threads per the "server", a listener thread and a traffic (receiver/server) thread. So -t
does a few things, it sets the listener thread timeout and the traffic threads' times. The listener thread is the parent of the traffic thread so it must wait for the traffic threads to complete before it can terminate.
Example: Let's say one issues iperf -s -t 30
which will keep the listener around for 30 seconds. If no clients present themselves within 30 seconds the "server" terminates after 30 seconds. But if 20 seconds after the iperf -s -t 30
a client connect, e.g. iperf -c <server> -t 30
, then the listener/server will to stay around for 20 + 30 seconds before terminating. (Note: The client's -t <value>
isn't passed to the server so the server -t
needs to be equal or greater than the clients -t
.)