Fix a crash when we try to print ending stats but no tests were run.

This can happen if the server gets into a weird state (see the test
cases for reproducing issue #212).  We need to do a couple of checks
to make sure we're not dereferencing NULL pointers (yay C).

While here, also fix up a couple of related output glitches, where
in this case we can emit some invalid JSON (NaN values, such as what
you get if there's a division by zero, are not valid JSON).

Part of a fix in progress for #212.

(cherry picked from commit 78033c4359834711dfe54efe10021d2f3d9f404c)
Signed-off-by: Bruce A. Mah <bmah@es.net>
Make UDP packet reception work right with non-blocking sockets and enable.

We need this to permit a UDP receiving iperf3 server to listen on its
control channel.

The fix for non-blocking sockets basically makes sure that if we do a
read on a non-blocking sockets, but there's no data, the UDP processing
code does *not* try to do the normal protocol packet processing on the
non-existent packet.

This is part of an ongoing fix for issue #212 but also should have been
a part of the fix for issue #125.

(cherry picked from commit 8694d1db0d0b95ea76ca2bfce79a01e48290bfce)
Signed-off-by: Bruce A. Mah <bmah@es.net>
The maximum send length for UDP is the maximum size of a UDP datagram.

For UDP over IPv4, this is the maximum IPv4 packet size (65535) minus
the size of the IPv4 and UDP headers, arriving at 65507.

In theory for a system implementing IPv6 jumbogram support, there is
no maximum packet size for UDP.  In practice we've observed with
CentOS 5 a limitation of 65535 - 8, which is dictated by the size
field in the UDP header (it has a maximum value of 65535, but needs
to count both payload and header bytes, thus subtracting off the 8
bytes for the UDP header).

We take the most conservative approach and use the 65507 value
for UDP / IPv4.

This is (I believe) the last part of issue #212.

(cherry picked from commit 96d0c77ca24da07d52f8d1c20301c202e4f0360b)
Signed-off-by: Bruce A. Mah <bmah@es.net>

Conflicts:
	src/iperf_api.h
	src/iperf_error.c