//Get the text to send from a file
do{
fgets(finpData, 1023, data_file);
if(!feof(data_file)) {
printf("%s", finpData);
numbytes += strlen(finpData);
fDatalen=strlen(finpData);
finpData[fDatalen-1]=0xd;
finpData[fDatalen]=0xa;
finpData[fDatalen+1]='\0';
strcpy(dtextbuf[prowdtext++], finpData);
}
}while(!feof(data_file));
prowdtextmx=prowdtext;
printf("Document read %d lines\n", prowdtextmx);
//We will continue to run the test as long as "go_again" is == 1. We enter this at the bottom
//of the loop
while(go_again == 1) {
//Get starting time
GetLocalTime(<);
//the vairable "timestosend" is set to 30
for(i = 0; i < timestosend; i++){
for(prowdtext=0; prowdtext < prowdtextmx; prowdtext++) {
send(sock, dtextbuf[prowdtext], strlen(dtextbuf[prowdtext]), 0);
}
}
//Get ending time
GetLocalTime(<1);
//Calculate time elapsed
et=(((int)lt1.wSecond + .001*(int)lt1.wMilliseconds) -((int)lt.wSecond + .001*(int)lt.wMilliseconds));
//Print the results & save to results file
printf("Data Sent: %d bytes in %f seconds\n", i*numbytes, et);
printf("%2.2f Meg bits per seconds\n", 8*(i*numbytes/et)/1000000);
fprintf(results_file, "Data Sent: %d bytes in %f seconds\n", i*numbytes, et);
fprintf(results_file, "%2.2f Meg bits per seconds\n", 8*(i*numbytes/et)/1000000);
printf("Go Again?\n");
scanf("%d", &go_again);
}
fclose(data_file);
fclose(results_file);