#include <sys/sendfile.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <sys/time.h>
#include <fcntl.h>
#include <string.h>
+#include <unistd.h>
#include <errno.h>
#include <netdb.h>
int fd[MAX_NUMBER_OF_PEERS];
int peers[MAX_NUMBER_OF_PEERS];
int i = 0, total, sent_size;
+ struct timeval start;
+ struct timeval stop;
if (argc < 4 || argc % 2) {
printf("Usage: %s <file_name> <peer_ip1> <peer_port1> <peer_ip2>"
total = i;
+ gettimeofday(&start, NULL);
do {
sent_size = 0;
usleep(20);
}
} while(sent_size);
+ gettimeofday(&stop, NULL);
+
+ printf("Successfully written %s in %ld seconds\n", file_name,
+ stop.tv_sec - start.tv_sec);
return 0;
}