Annotation of embedaddon/iperf/examples/mis.c, revision 1.1
1.1 ! misho 1: #include "iperf_config.h"
! 2:
! 3: #include <stdio.h>
! 4: #include <stdlib.h>
! 5: #include <unistd.h>
! 6: #include <string.h>
! 7: #include <sysexits.h>
! 8: #ifdef HAVE_STDINT_H
! 9: #include <stdint.h>
! 10: #endif
! 11:
! 12: #include <iperf_api.h>
! 13:
! 14: int
! 15: main( int argc, char** argv )
! 16: {
! 17: char* argv0;
! 18: int port;
! 19: struct iperf_test *test;
! 20: int consecutive_errors;
! 21:
! 22: argv0 = strrchr( argv[0], '/' );
! 23: if ( argv0 != (char*) 0 )
! 24: ++argv0;
! 25: else
! 26: argv0 = argv[0];
! 27:
! 28: if ( argc != 2 ) {
! 29: fprintf( stderr, "usage: %s [port]\n", argv0 );
! 30: exit( EXIT_FAILURE );
! 31: }
! 32: port = atoi( argv[1] );
! 33:
! 34: test = iperf_new_test();
! 35: if ( test == NULL ) {
! 36: fprintf( stderr, "%s: failed to create test\n", argv0 );
! 37: exit( EXIT_FAILURE );
! 38: }
! 39: iperf_defaults( test );
! 40: iperf_set_verbose( test, 1 );
! 41: iperf_set_test_role( test, 's' );
! 42: iperf_set_test_server_port( test, port );
! 43:
! 44: consecutive_errors = 0;
! 45: for (;;) {
! 46: if ( iperf_run_server( test ) < 0 ) {
! 47: fprintf( stderr, "%s: error - %s\n\n", argv0, iperf_strerror( i_errno ) );
! 48: ++consecutive_errors;
! 49: if (consecutive_errors >= 5) {
! 50: fprintf(stderr, "%s: too many errors, exiting\n", argv0);
! 51: break;
! 52: }
! 53: } else
! 54: consecutive_errors = 0;
! 55: iperf_reset_test( test );
! 56: }
! 57:
! 58: iperf_free_test( test );
! 59: exit( EXIT_SUCCESS );
! 60: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>