Changeset 1630:b7db925dbfd1 in roaraudio
- Timestamp:
- 04/28/09 12:38:49 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarctl.c
r1585 r1630 26 26 #include <pwd.h> 27 27 #include <grp.h> 28 #include <sys/time.h> 29 #include <time.h> 28 30 29 31 int g_verbose = 0; … … 46 48 " help - Show this help\n" 47 49 " sleep TIME - Sleeps for TIME seconds\n" 50 " ping NUM - Do NUM pings using NOOP commands\n" 48 51 "\n" 49 52 " standby, off - Go into standby mode\n" … … 81 84 } 82 85 86 int ping (struct roar_connection * con, int num) { 87 struct timeval try, ans; 88 struct roar_message m; 89 register int ret; 90 int i; 91 92 for (i = 0; i < num; i++) { 93 m.cmd = ROAR_CMD_NOOP; 94 m.datalen = 0; 95 96 gettimeofday(&try, NULL); 97 ret = roar_req(con, &m, NULL); 98 gettimeofday(&ans, NULL); 99 100 if ( ret == -1 ) 101 return -1; 102 103 while (ans.tv_sec > try.tv_sec) { 104 ans.tv_sec--; 105 ans.tv_usec += 1000000; 106 } 107 ans.tv_usec -= try.tv_usec; 108 109 printf("Pong from server: seq=%i time=%.2fms\n", i, ans.tv_usec/1000.0); 110 111 if ( i != (num - 1) ) 112 sleep(1); 113 } 114 115 return 0; 116 } 117 83 118 void server_oinfo (struct roar_connection * con) { 84 119 struct roar_stream s; … … 621 656 sleep(atoi(argv[++i])); 622 657 658 } else if ( !strcmp(k, "ping") ) { 659 if ( ping(&con, atoi(argv[++i])) == -1 ) { 660 fprintf(stderr, "Error: can not ping\n"); 661 } 662 623 663 } else if ( !strcmp(k, "standby") || !strcmp(k, "off") ) { 624 664 if ( roar_set_standby(&con, ROAR_STANDBY_ACTIVE) == -1 ) {
Note: See TracChangeset
for help on using the changeset viewer.