diff -urN udpcast.orig/Makefile udpcast/Makefile
--- udpcast.orig/Makefile	2001-11-13 15:15:14.000000000 -0600
+++ udpcast/Makefile	2003-01-22 19:27:49.000000000 -0600
@@ -1,9 +1,10 @@
 #CFLAGS = -O4 -Wall -DNDEBUG -DLOSSTEST
-CFLAGS =-O10 -Wall
-LDFLAGS =-s
+#CFLAGS =-O10 -Wall
+CFLAGS = -g -O3 -Wall
+LDFLAGS = -g -s 
 LIBS=-lpthread
 
-all: udp-receiver udp-sender udp-receiver.1 udp-sender.1
+all: udp-receiver udp-sender udp-receiver.1.gz udp-sender.1.gz
 #all: fec-test
 
 disk: udpcast.img.gz
@@ -11,11 +12,11 @@
 #disks: sender.img.gz receiver.img.gz
 
 clean:
-	rm -f *.o udp-sender udp-receiver udp-sender.1 udp-receiver.1 *~
+	rm -f *.o udp-sender udp-receiver udp-sender.1* udp-receiver.1* *~
 
 install: udp-sender udp-receiver
-	cp udp-sender udp-receiver /usr/sbin
-	cp udp-sender.1 udp-receiver.1 /usr/share/man/man1
+	install -m 555 udp-sender udp-receiver /usr/sbin
+	install -m 644 udp-sender.1.gz udp-receiver.1.gz /usr/share/man/man1
 
 udp-sender: udp-sender.o socklib.o udpcast.o rate-limit.o \
 	sender-diskio.o senddata.o udps-negotiate.o \
@@ -29,8 +30,9 @@
 	fifo.o log.o statistics.o fec.o version.o
 	gcc $(LDFLAGS) $^ -lpthread -o $@
 
-udp-receiver.1 udp-sender.1: html2man.pl cmd.html
-	html2man.pl <cmd.html
+udp-receiver.1.gz udp-sender.1.gz: html2man.pl cmd.html
+	./html2man.pl <cmd.html
+	gzip -9 udp-receiver.1 udp-sender.1
 
 fec-test: fec-test.o
 	gcc $(LDFLAGS) $^ -o $@
diff -urN udpcast.orig/Makefile.orig udpcast/Makefile.orig
--- udpcast.orig/Makefile.orig	1969-12-31 18:00:00.000000000 -0600
+++ udpcast/Makefile.orig	2003-01-22 19:27:40.000000000 -0600
@@ -0,0 +1,41 @@
+#CFLAGS = -O4 -Wall -DNDEBUG -DLOSSTEST
+#CFLAGS =-O10 -Wall
+CFLAGS = -g -O3 -Wall
+LDFLAGS = -g -s 
+LIBS=-lpthread
+
+all: udp-receiver udp-sender udp-receiver.1 udp-sender.1
+#all: fec-test
+
+disk: udpcast.img.gz
+
+#disks: sender.img.gz receiver.img.gz
+
+clean:
+	rm -f *.o udp-sender udp-receiver udp-sender.1 udp-receiver.1 *~
+
+install: udp-sender udp-receiver
+	cp udp-sender udp-receiver /usr/sbin
+	cp udp-sender.1 udp-receiver.1 /usr/share/man/man1
+
+udp-sender: udp-sender.o socklib.o udpcast.o rate-limit.o \
+	sender-diskio.o senddata.o udps-negotiate.o \
+	fifo.o produconsum.o participants.o log.o statistics.o \
+	fec.o version.o
+	gcc $(LDFLAGS) $^ -lpthread -o $@
+
+
+udp-receiver: udp-receiver.o socklib.o udpcast.o \
+	receiver-diskio.o receivedata.o udpr-negotiate.o produconsum.o \
+	fifo.o log.o statistics.o fec.o version.o
+	gcc $(LDFLAGS) $^ -lpthread -o $@
+
+udp-receiver.1 udp-sender.1: html2man.pl cmd.html
+	html2man.pl <cmd.html
+
+fec-test: fec-test.o
+	gcc $(LDFLAGS) $^ -o $@
+
+fec.o: fec.c
+	gcc -c $(CFLAGS) -fno-inline $<
+
diff -urN udpcast.orig/cmd.html udpcast/cmd.html
--- udpcast.orig/cmd.html	2001-12-31 01:03:10.000000000 -0600
+++ udpcast/cmd.html	2003-01-22 19:27:40.000000000 -0600
@@ -34,7 +34,7 @@
 <!-- =text Alain Knaff -->
 <!-- =section udp-sender SYNOPSIS -->
 <!-- =text
-udp-sender [--file <i>file</i>] [--full-duplex] [--half-duplex] [--pipe <i>pipe</i>] [--portbase <i>portbase</i>] [--blocksize <i>size</i>] [--interface <i>net-interface</i>] [--mcast-addr <i>data-mcast-address</i>] [--mcast-all-addr <i>mcast-all-address</i>] [--max-bitrate <i>bitrate</i>] [--pointopoint</i>] [--async] [--log <i>file</i>] [--min-slice-size <i>min</i>] [--max-slice-size <i>max</i>] [--slice-size] [--ttl <i>time-to-live</i>] [--fec <i>stripes</i>x<i>redundancy</i>/<i>stripesize</i>] [--print-seed] [--rexmit-hello-interval <i>interval</i>] [--autostart <i>autostart</i>] [--broadcast]
+udp-sender [--file <i>file</i>] [--full-duplex] [--half-duplex] [--pipe <i>pipe</i>] [--portbase <i>portbase</i>] [--blocksize <i>size</i>] [--interface <i>net-interface</i>] [--mcast-addr <i>data-mcast-address</i>] [--mcast-all-addr <i>mcast-all-address</i>] [--max-bitrate <i>bitrate</i>] [--pointopoint</i>] [--async] [--log <i>file</i>] [--min-slice-size <i>min</i>] [--max-slice-size <i>max</i>] [--slice-size] [--ttl <i>time-to-live</i>] [--fec <i>stripes</i>x<i>redundancy</i>/<i>stripesize</i>] [--print-seed] [--rexmit-hello-interval <i>interval</i>] [--autostart <i>autostart</i>] [--broadcast] [--min-clients <i>clients</i>] [--min-client-wait <i>sec</i>] [--max-client-wait <i>sec</i>]
 <!-- =stop -->
 <!-- =cont -->
 
diff -urN udpcast.orig/fec.c udpcast/fec.c
--- udpcast.orig/fec.c	2001-08-10 05:11:28.000000000 -0500
+++ udpcast/fec.c	2003-01-22 19:27:40.000000000 -0600
@@ -1,4 +1,4 @@
-#define USE_ASSEMBLER
+/*#define USE_ASSEMBLER*/
 /*#define PROFILE*/
 /*
  * fec.c -- forward error correction based on Vandermonde matrices
diff -urN udpcast.orig/participants.h udpcast/participants.h
--- udpcast.orig/participants.h	2001-11-15 13:21:06.000000000 -0600
+++ udpcast/participants.h	2003-01-22 19:27:40.000000000 -0600
@@ -1,7 +1,10 @@
 #ifndef PARTICIPANTS_H
 #define PARTICIPANTS_H
 
+/*
 #define MAX_CLIENTS 256
+*/
+#define MAX_CLIENTS 1024
 
 #include <sys/socket.h>
 
diff -urN udpcast.orig/udp-sender.c udpcast/udp-sender.c
--- udpcast.orig/udp-sender.c	2001-12-30 18:04:27.000000000 -0600
+++ udpcast/udp-sender.c	2003-01-22 19:27:55.000000000 -0600
@@ -13,6 +13,7 @@
 #include "rate-limit.h"
 #include "version.h"
 
+
 static struct option options[] = {
     { "file", 1, NULL, 'f' },
     { "half-duplex", 0, NULL, 'c' },
@@ -61,10 +62,14 @@
     { "autostart", 1, NULL, 0x702 },
 
     { "broadcast", 0, NULL, 0x801 },
+
+    { "min-clients", 1, NULL, 0x901 },
+    { "max-client-wait", 1, NULL, 0x902 },
+    { "min-client-wait", 1, NULL, 0x903 },
 };
 
 void usage(char *progname) {
-    fprintf(stderr, "%s [--file file] [--full-duplex] [--pipe pipe] [--portbase portbase] [--blocksize size] [--interface net-interface] [--mcast-addr data-mcast-address] [--mcast-all-addr mcast-all-address] [--max-bitrate bitrate] [--pointopoint] [--async] [--log file] [--min-slice-size min] [--max-slice-size max] [--slice-size] [--ttl time-to-live] [--fec <stripes>x<redundancy>/<stripesize>] [--print-seed] [--rexmit-hello-interval interval] [--autostart autostart] [--broadcast]\n", progname);
+    fprintf(stderr, "%s [--file file] [--full-duplex] [--half-duplex] [--pipe pipe] [--portbase portbase] [--blocksize size] [--interface net-interface] [--mcast-addr data-mcast-address] [--mcast-all-addr mcast-all-address] [--max-bitrate bitrate] [--pointopoint] [--async] [--log file] [--min-slice-size min] [--max-slice-size max] [--slice-size] [--ttl time-to-live] [--fec <stripes>x<redundancy>/<stripesize>] [--print-seed] [--rexmit-hello-interval interval] [--autostart autostart] [--broadcast] [--min-clients clients] [--min-client-wait sec] [--max-client-wait sec]\n", progname);
     exit(1);
 }
 
@@ -100,6 +105,9 @@
     net_config.ttl = 1;
     net_config.rexmit_hello_interval = 0;
     net_config.autostart = 0;
+    net_config.min_clients=0;
+    net_config.max_client_wait=0;
+    net_config.min_client_wait=0;
 
     ptr = strrchr(argv[0], '/');
     if(!ptr)
@@ -269,6 +277,15 @@
 		case 0x801:
 		    net_config.flags |= FLAG_BCAST;
 		    break;		    
+		case 0x901:
+		    net_config.min_clients = atoi(optarg);
+		    break;		    
+		case 0x902:
+		    net_config.max_client_wait = atoi(optarg);
+		    break;		    
+		case 0x903:
+		    net_config.min_client_wait = atoi(optarg);
+		    break;		    
 		case '?':
 		    usage(argv[0]);
 	    }
diff -urN udpcast.orig/udp-sender.c.orig udpcast/udp-sender.c.orig
--- udpcast.orig/udp-sender.c.orig	1969-12-31 18:00:00.000000000 -0600
+++ udpcast/udp-sender.c.orig	2003-01-22 19:27:40.000000000 -0600
@@ -0,0 +1,348 @@
+#include <sys/types.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <unistd.h>
+#include <sys/socket.h>
+
+#include "log.h"
+#include "socklib.h"
+#include "udpcast.h"
+#include "udp-sender.h"
+#include "rate-limit.h"
+#include "version.h"
+
+
+static struct option options[] = {
+    { "file", 1, NULL, 'f' },
+    { "half-duplex", 0, NULL, 'c' },
+    { "full-duplex", 0, NULL, 'd' },
+    { "pipe", 1, NULL, 'p' },
+    { "port", 1, NULL, 'P' },
+    { "portbase", 1, NULL, 'P' },
+    { "blocksize", 1, NULL, 'b' },
+    { "interface", 1, NULL, 'i' },
+    { "mcast_addr", 1, NULL, 'm' },
+    { "mcast-addr", 1, NULL, 'm' },
+    { "mcast_all_addr", 1, NULL, 'M' },
+    { "mcast-all-addr", 1, NULL, 'M' },
+    { "max_bitrate", 1, NULL, 'r' },
+    { "max-bitrate", 1, NULL, 'r' },
+    { "point-to-point", 0, NULL, '1' },
+    { "point_to_point", 0, NULL, '1' },
+    { "pointopoint", 0, NULL, '1' },
+
+    { "nopoint-to-point", 0, NULL, '2' },
+    { "nopoint_to_point", 0, NULL, '2' },
+    { "nopointopoint", 0, NULL, '2' },
+
+    { "async", 0, NULL, 'a' },
+    { "autorate", 0, NULL, 'A' },
+    { "log", 1, NULL, 'l' },
+
+    /* slice size configuration */
+    { "min-slice-size", 1, NULL, 0x0101 },
+    { "default-slice-size", 1, NULL, 0x0102 },
+    { "slice-size", 1, NULL, 0x0102 },
+    { "max-slice-size", 1, NULL, 0x0103 },
+
+    { "ttl", 1, NULL, 0x0401 },
+    { "fec", 1, NULL, 0x0502 },
+
+#if LOSSTEST
+    /* simulating packet loss */
+    { "write-loss", 1, NULL, 0x601 },
+    { "read-loss", 1, NULL, 0x602 },
+    { "seed", 1, NULL, 0x603 },
+    { "print-seed", 0, NULL, 0x604 },
+#endif
+
+    { "rexmit-hello-interval", 1, NULL, 0x701 },
+    { "autostart", 1, NULL, 0x702 },
+
+    { "broadcast", 0, NULL, 0x801 },
+
+    { "min-clients", 1, NULL, 0x901 },
+    { "max-client-wait", 1, NULL, 0x902 },
+    { "min-client-wait", 1, NULL, 0x903 },
+};
+
+void usage(char *progname) {
+    fprintf(stderr, "%s [--file file] [--full-duplex] [--pipe pipe] [--portbase portbase] [--blocksize size] [--interface net-interface] [--mcast-addr data-mcast-address] [--mcast-all-addr mcast-all-address] [--max-bitrate bitrate] [--pointopoint] [--async] [--log file] [--min-slice-size min] [--max-slice-size max] [--slice-size] [--ttl time-to-live] [--fec <stripes>x<redundancy>/<stripesize>] [--print-seed] [--rexmit-hello-interval interval] [--autostart autostart] [--broadcast]\n", progname);
+    exit(1);
+}
+
+
+int main(int argc, char **argv)
+{
+    int c;
+    char *ptr;
+#ifdef LOSSTEST
+    int seedSet = 0;
+    int printSeed = 0;
+#endif
+
+    struct net_config net_config;
+    struct disk_config disk_config;
+
+    /* argument parsing */
+    disk_config.fileName = NULL;
+    disk_config.pipeName = NULL;
+    disk_config.flags = 0;
+
+    clearIp(&net_config.dataMcastAddr);
+    net_config.mcastAll = NULL;
+    net_config.blockSize = 1456;
+    net_config.sliceSize = 16;
+    net_config.portBase = 9000;
+    net_config.rateLimit = NULL;
+    net_config.flags = 0;
+    net_config.capabilities = 0;
+    net_config.min_slice_size = 16;
+    net_config.max_slice_size = 1024;
+    net_config.default_slice_size = 0;
+    net_config.ttl = 1;
+    net_config.rexmit_hello_interval = 0;
+    net_config.autostart = 0;
+    net_config.min_clients=0;
+    net_config.max_client_wait=0;
+    net_config.min_client_wait=0;
+
+    ptr = strrchr(argv[0], '/');
+    if(!ptr)
+	ptr = argv[0];
+    else
+	ptr++;
+
+    net_config.net_if = getenv("IFNAME");
+    if (!net_config.net_if)
+	net_config.net_if = "eth0";
+    if (strcmp(ptr, "init") == 0) {
+	disk_config.pipeName = strdup("/bin/gzip -c");
+	disk_config.fileName = "/dev/hda";
+    } else {
+	while( (c=getopt_long(argc, argv, 
+			      "f:p:P:b:i:m:l:r:a1AcdM:",
+			      options, NULL)) != EOF ) {
+	    switch(c) {
+		case 'a':
+		    net_config.flags |= FLAG_ASYNC|FLAG_SN;
+		    break;
+		case 'c':
+		    net_config.flags &= ~FLAG_SN;
+		    break;
+		case 'd':
+		    net_config.flags |= FLAG_SN;
+		    break;		    
+		case 'f':
+		    disk_config.fileName=optarg;
+		    break;
+		case 'i':
+		    net_config.net_if=optarg;
+		    break;
+		case 'p':
+		    disk_config.pipeName=optarg;
+		    break;
+		case 'P':
+		    net_config.portBase = atoi(optarg);
+		    break;
+		case '1':
+		    net_config.flags |= FLAG_POINTOPOINT;
+		    break;
+		case '2':
+		    net_config.flags |= FLAG_NOPOINTOPOINT;
+		    break;
+		case 'b':
+		    net_config.blockSize = strtoul(optarg, 0, 0);
+		    net_config.blockSize -= net_config.blockSize % 4;
+		    if (net_config.blockSize <= 0) {
+			perror("block size too small");
+			exit(1);
+		    }
+#if 0
+		    if (net_config.blockSize > 1456) {
+			perror("block size too large");
+			exit(1);
+		    }
+#endif
+		    break;
+		case 'l':
+		    log = fopen(optarg, "a");
+		    break;
+		case 'm':
+		    setIpFromString(&net_config.dataMcastAddr, optarg);
+		    fprintf(stderr, "MC=x %p %p\n", 
+			    &net_config,
+			    &net_config.dataMcastAddr);
+		    ipIsZero(&net_config.dataMcastAddr);
+		    break;
+		case 'M':
+		    net_config.mcastAll = strdup(optarg);
+		    break;
+		case 'r':
+		    {
+			char *eptr;
+			int bitrate = strtoul(optarg, &eptr, 10);
+			if(eptr && *eptr) {
+			    switch(*eptr) {
+				case 'm':
+				case 'M':
+				    bitrate *= 1000000;
+				    break;
+			    case 'k':
+				case 'K':
+				    bitrate *= 1000;
+				    break;
+			    }
+			}
+			net_config.rateLimit=allocRateLimit(bitrate);
+		    }
+		    break;
+		case 'A':
+		    net_config.flags |= FLAG_AUTORATE;
+		    break;
+		case 0x0101:
+		    net_config.min_slice_size = atoi(optarg);
+		    if(net_config.min_slice_size > MAX_SLICE_SIZE)
+			fatal(1, "min slice size too big\n");
+		    break;
+		case 0x0102:
+		    net_config.default_slice_size = atoi(optarg);
+		    break;
+		case 0x0103:
+		    net_config.max_slice_size = atoi(optarg);
+		    if(net_config.max_slice_size > MAX_SLICE_SIZE)
+			fatal(1, "max slice size too big\n");
+		    break;
+		case 0x0401:
+		    net_config.ttl = atoi(optarg);
+		    break;
+		case 0x502:
+		    net_config.flags |= FLAG_FEC;
+		    {
+			char *ptr, *eptr;
+			ptr = strchr(optarg, 'x');
+			if(ptr) {
+			    net_config.fec_stripes = 
+				strtoul(optarg, &eptr, 10);
+			    if(ptr != eptr) {
+				flprintf("%s != %s\n", ptr, eptr);
+				usage(argv[0]);
+			    }
+			    ptr++;
+			} else {
+			    net_config.fec_stripes = 8;
+			    ptr = optarg;
+			}
+			net_config.fec_redundancy = strtoul(ptr, &eptr, 10);
+			if(*eptr == '/') {
+			    ptr = eptr+1;
+			    net_config.fec_stripesize = 
+				strtoul(ptr, &eptr, 10);
+			} else {
+			    net_config.fec_stripesize = 128;
+			}
+			if(*eptr) {
+			    flprintf("string not at end %s\n", eptr);
+			    usage(argv[0]);
+			}
+			fprintf(stderr, "stripes=%d redund=%d stripesize=%d\n",
+				net_config.fec_stripes,
+				net_config.fec_redundancy,
+				net_config.fec_stripesize);
+		    }
+		    break;
+#ifdef LOSSTEST
+		case 0x601:
+		    setWriteLoss(optarg);
+		    break;
+		case 0x602:
+		    setReadLoss(optarg);
+		    break;
+		case 0x603:
+		    seedSet=1;
+		    srandom(strtoul(optarg,0,0));
+		    break;
+		case 0x604:
+		    printSeed=1;
+		    break;
+#endif
+		case 0x701:
+		    net_config.rexmit_hello_interval = atoi(optarg);
+		    break;
+		case 0x702:
+		    net_config.autostart = atoi(optarg);
+		    break;
+		case 0x801:
+		    net_config.flags |= FLAG_BCAST;
+		    break;		    
+		case 0x901:
+		    net_config.min_clients = atoi(optarg);
+		    break;		    
+		case 0x902:
+		    net_config.max_client_wait = atoi(optarg);
+		    break;		    
+		case 0x903:
+		    net_config.min_client_wait = atoi(optarg);
+		    break;		    
+		case '?':
+		    usage(argv[0]);
+	    }
+	}
+    }
+
+    if((net_config.flags & FLAG_POINTOPOINT) &&
+       (net_config.flags & FLAG_NOPOINTOPOINT)) {
+	fatal(1,"pointopoint and nopointopoint cannot be set both\n");
+    }
+
+    if( (net_config.autostart || (net_config.flags & FLAG_ASYNC)) &&
+	net_config.rexmit_hello_interval == 0)
+	net_config.rexmit_hello_interval = 1000;
+
+#ifdef LOSSTEST
+    if(!seedSet)
+	srandomTime(printSeed);
+#endif
+    if(net_config.flags &  FLAG_ASYNC) {
+	if(net_config.rateLimit == 0) {
+	    fprintf(stderr, 
+		    "Async mode chosen but no rate-limit ==> unsafe\n");
+	    fprintf(stderr, 
+		    "Transmission would fail due to buffer overrung\n");
+	    fprintf(stderr, 
+		    "Add \"--max-bitrate 9500k\" to commandline (for example)\n");
+	    exit(1);
+	}
+	if(! (net_config.flags & FLAG_FEC)) {
+	    fprintf(stderr, 
+		    "Warning: Async mode but no forward error correction\n");
+	    fprintf(stderr, 
+		    "Transmission may fail due to packet loss\n");
+	    fprintf(stderr, 
+		    "Add \"--fec 8x8\" to commandline\n");
+	}
+    }
+
+    if(net_config.min_slice_size < 1)
+	net_config.min_slice_size = 1;
+    if(net_config.max_slice_size < net_config.min_slice_size)
+	net_config.max_slice_size = net_config.min_slice_size;
+    if(net_config.default_slice_size != 0) {
+	if(net_config.default_slice_size < net_config.min_slice_size)
+	    net_config.default_slice_size = net_config.min_slice_size;
+	if(net_config.default_slice_size > net_config.max_slice_size)
+	    net_config.default_slice_size = net_config.max_slice_size;
+    }
+
+    fprintf(stderr, "Udp-sender %s\n", version);
+
+    /*
+    if(disk_config.fileName == NULL && disk_config.pipeName == NULL) {
+	fatal(1, "You must supply file or pipe\n");
+    }
+     end of argument parsing */
+
+    return startSender(&disk_config, &net_config);
+}
diff -urN udpcast.orig/udpcast.h udpcast/udpcast.h
--- udpcast.orig/udpcast.h	2001-12-30 18:00:55.000000000 -0600
+++ udpcast/udpcast.h	2003-01-22 19:27:40.000000000 -0600
@@ -91,6 +91,9 @@
 				* If 0, hello message won't be retransmitted
 				*/
     int autostart; /* autostart after that many retransmits */
+    int min_clients;
+    int max_client_wait;
+    int min_client_wait;
 };
 
 #define MAX_SLICE_SIZE 1024
diff -urN udpcast.orig/udps-negotiate.c udpcast/udps-negotiate.c
--- udpcast.orig/udps-negotiate.c	2001-12-30 18:07:32.000000000 -0600
+++ udpcast/udps-negotiate.c	2003-01-22 19:27:40.000000000 -0600
@@ -1,6 +1,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <time.h>
 
 #include "log.h"
 #include "fifo.h"
@@ -12,6 +13,9 @@
 #include "participants.h"
 #include "statistics.h"
 
+static time_t maxSendWait=0;
+static time_t minSendWait=0;
+
 /**
  * This file contains the code to set up the connection
  */
@@ -105,8 +109,18 @@
     int ret;
     int msgLength;
 
-    if (nrParticipants(db))
+    if (nrParticipants(db)){
+	time_t now = time(0);
 	flprintf("Ready. Press any key to start sending data.\n");
+ 	if(net_config->max_client_wait && (maxSendWait < 1)){
+		maxSendWait = now + net_config->max_client_wait;
+	}
+ 	if(net_config->min_client_wait && (minSendWait < 1)){
+		minSendWait = now + net_config->min_client_wait;
+	}
+    } else {
+	maxSendWait = 0;
+    }
  
     while(1) {
 	struct timeval tv;
@@ -121,11 +135,16 @@
 	    tv.tv_usec = (net_config->rexmit_hello_interval % 1000)*1000;
 	    tv.tv_sec = net_config->rexmit_hello_interval / 1000;
 	    tvp = &tv;
-	} else
+	} else if(nrParticipants(db)) {
+	    tv.tv_usec = 0;
+	    tv.tv_sec = 2;
+	    tvp = &tv;
+	} else {
 	    tvp = 0;
+	}
 	nr_desc = select(fd+1,  &read_set, 0, 0,  tvp);
 	if(nr_desc < 0) {
-	    perror("select");
+	    perror("%d select");
 	    exit(1);
 	}
 	if(nr_desc == 0) {
@@ -137,9 +156,43 @@
 	    }
 	} else
 	    break;
+	if (nrParticipants(db)){
+		time_t now = time(0);
+		/*
+		 * Bad if statement...
+		 *  If the maxSendWait time has passed transfer the data
+		 */
+		if(net_config->max_client_wait && (now >= maxSendWait)){
+			doTransfer(fd, db, disk_config, net_config);
+			return 1;
+			/*
+			 * Otherwise check to see if the minimum of clients
+			 *  have checked in.
+			 */
+		} else if ((nrParticipants(db) >= net_config->min_clients)){
+	 		/*
+			 *  If they have and there's a min wait time, we'll 
+			 *    wait around anyway until then.
+			 */
+			if(net_config->min_client_wait){
+			    if(now >= minSendWait){
+				doTransfer(fd, db, disk_config, net_config);
+				return 1;
+    }
+			} else {
+			/*
+			 * Otherwise we transver the data.
+			 */
+			    doTransfer(fd, db, disk_config, net_config);
+			    return 1;
+			}
+		}
+	}
     }
+	
 
     if(keyboard) {
+	flprintf("KBD-ing.\n");
 	if(FD_ISSET(0, &read_set)) {
 	    char line[80];
 	    read(0, line, 80);
@@ -163,6 +216,7 @@
     if(net_config->flags & FLAG_ASYNC)
 	return 0;
 
+	flprintf("Checking Connections.\n");
     switch(ntohs(fromClient.opCode)) {
 	case CMD_CONNECT_REQ:
 	    sendConnectionReply(db, fd,
@@ -308,6 +362,7 @@
     int origIn;
     int pid;
     int isPtP = isPointToPoint(db, net_config->flags);
+    time_t stTime = time(0);
 
     if((net_config->flags & FLAG_POINTOPOINT) &&
        nrParticipants(db) != 1) {
@@ -329,6 +384,7 @@
 	}
 
 
+    flprintf("%s", ctime(&stTime));
     flprintf("Starting transfer: %08x\n", net_config->capabilities);
 
     if(net_config->capabilities & CAP_BIG_ENDIAN)
@@ -361,5 +417,6 @@
 	removeParticipant(db, i);
     }
     flprintf("\n");
+  
     return 0;
 }
