Annotation of embedaddon/iperf/examples/mic.c, revision 1.1.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: char* host;
19: int port;
20: struct iperf_test *test;
21:
22: argv0 = strrchr( argv[0], '/' );
23: if ( argv0 != (char*) 0 )
24: ++argv0;
25: else
26: argv0 = argv[0];
27:
28: if ( argc != 3 ) {
29: fprintf( stderr, "usage: %s [host] [port]\n", argv0 );
30: exit( EXIT_FAILURE );
31: }
32: host = argv[1];
33: port = atoi( argv[2] );
34:
35: test = iperf_new_test();
36: if ( test == NULL ) {
37: fprintf( stderr, "%s: failed to create test\n", argv0 );
38: exit( EXIT_FAILURE );
39: }
40: iperf_defaults( test );
41: iperf_set_verbose( test, 1 );
42:
43: iperf_set_test_role( test, 'c' );
44: iperf_set_test_server_hostname( test, host );
45: iperf_set_test_server_port( test, port );
46: /* iperf_set_test_reverse( test, 1 ); */
47: iperf_set_test_omit( test, 3 );
48: iperf_set_test_duration( test, 5 );
49: iperf_set_test_reporter_interval( test, 1 );
50: iperf_set_test_stats_interval( test, 1 );
51: /* iperf_set_test_json_output( test, 1 ); */
52:
53: if ( iperf_run_client( test ) < 0 ) {
54: fprintf( stderr, "%s: error - %s\n", argv0, iperf_strerror( i_errno ) );
55: exit( EXIT_FAILURE );
56: }
57:
58: if (iperf_get_test_json_output_string(test)) {
59: fprintf(iperf_get_test_outfile(test), "%zd bytes of JSON emitted\n",
60: strlen(iperf_get_test_json_output_string(test)));
61: }
62:
63: iperf_free_test( test );
64: exit( EXIT_SUCCESS );
65: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>