File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / iperf / examples / mis.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:36:45 2021 UTC (3 years, 3 months ago) by misho
Branches: iperf, MAIN
CVS tags: v3_3_9, v3_15, HEAD
iperf 3.3.9

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>