added -D option
authorAndrew Tridgell <tridge@samba.org>
Thu, 21 Aug 2008 23:31:14 +0000 (09:31 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 21 Aug 2008 23:31:14 +0000 (09:31 +1000)
socklib/sock_sink.c

index 715b9f5add353f4ee7701d8a412837771accbfea..576c12d822ccb15669e1bfc7e9357cab10067726 100644 (file)
@@ -10,6 +10,7 @@ static int port=7001;
 static int bufsize=0x10000;
 static char *host="127.0.0.1";
 static const char *outfile;
+static unsigned delay_per_packet;
 
 static void sender(void)
 {
@@ -47,6 +48,9 @@ static void sender(void)
                                exit(1);
                        }
                }
+               if (delay_per_packet) {
+                       usleep(delay_per_packet);
+               }
                total += ret;
                if (end_timer() > 2.0) {
                        report_time(total);
@@ -59,7 +63,7 @@ static void sender(void)
 
 static void usage(void)
 {
-       printf("-p port\n-t socket options\n-H host\n-b bufsize [-F outfile]\n\n");
+       printf("-p port\n-t socket options\n-H host\n-b bufsize [-F outfile] [-D delay]\n\n");
 }
 
 int main(int argc, char *argv[])
@@ -67,7 +71,7 @@ int main(int argc, char *argv[])
        int opt;
        extern char *optarg;
 
-       while ((opt = getopt (argc, argv, "p:t:H:b:hF:")) != EOF) {
+       while ((opt = getopt (argc, argv, "p:t:H:b:hF:D:")) != EOF) {
                switch (opt) {
                case 'p':
                        port = strtol(optarg, NULL, 0);
@@ -84,6 +88,9 @@ int main(int argc, char *argv[])
                case 'F':
                        outfile = optarg;
                        break;
+               case 'D':
+                       delay_per_packet = strtoul(optarg, NULL, 0);
+                       break;
 
                case 'h':
                default: