summaryrefslogtreecommitdiff
path: root/mcastseed
diff options
context:
space:
mode:
Diffstat (limited to 'mcastseed')
-rw-r--r--mcastseed/src/Makefile.am3
-rw-r--r--mcastseed/src/random_speed_dd.c32
2 files changed, 34 insertions, 1 deletions
diff --git a/mcastseed/src/Makefile.am b/mcastseed/src/Makefile.am
index 7ad2954..547d715 100644
--- a/mcastseed/src/Makefile.am
+++ b/mcastseed/src/Makefile.am
@@ -4,9 +4,10 @@ AM_CFLAGS =\
-Wall \
-g
-bin_PROGRAMS = mcastseed mcastleech
+bin_PROGRAMS = mcastseed mcastleech random_speed_dd
mcastseed_SOURCES = mcastseed.c msock.c
mcastleech_SOURCES = mcastleech.c msock.c dgrambuf.c
+random_speed_dd_SOURCES = random_speed_dd.c
LDADD = @WSOCKLIB@
diff --git a/mcastseed/src/random_speed_dd.c b/mcastseed/src/random_speed_dd.c
new file mode 100644
index 0000000..0c11c05
--- /dev/null
+++ b/mcastseed/src/random_speed_dd.c
@@ -0,0 +1,32 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+char buf[0xffff];
+
+int main() {
+ size_t nread, nwrite, remains;
+
+ srandom(1); // Always the same pseudo-random sequence
+
+ while ( (nread=read(0, buf, 0xf & rand())) >= 0 ) {
+ remains = nread;
+ while ( remains ) {
+ nwrite=write(1, buf, nread);
+ if ( nwrite < 0 ) {
+ if ( !(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) ) {
+ perror("write");
+ return nwrite;
+ }
+ } else {
+ remains -= nwrite;
+ }
+ }
+ //fprintf(stderr, "nread==%zi, nwrite==%zi\n", nread, nwrite);
+ usleep( 0xfffff & rand() );
+ }
+
+ return 0;
+}
+