So how would i set conditions in the for loop if i do not know the size of the file until the end of the loop? I figure thats why the server is making an extra read call. It is looping until the data is read, then looping one extra time resulting in the extra call to read.
Read the manual on read() and re-examine your logic.
readfd = read(newsockfd, buffer, sizeof(buffer));
if(readfd < 0)
fprintf(stderr, "%s. READ(s)\n", strerror(errno));
//Test to see if the buffer is blank.
if(readfd == 0)
printf("Null buffer. READ()\n");
Oh, and I wouldn't call the variable receiving the return value from read "readfd", as it implies it's a read file descriptor. Use something a little more sane and descriptive, like "bytes_read".
Thanks rags_to_riches, I solved the problem.