Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #define CHUNK 100
  2. void ReadAndSendFile(File *file, int totalFileSize , int sockfd)
  3. {
  4. char buffer[CHUNK] = {0};
  5. int remainingBytes = totalFileSize;
  6. int currBytesToRead = 0;
  7.  
  8. while(remainingBytes > 0)
  9. {
  10. currBytesToRead = minimum(remainingBytes,CHUNK);
  11. remainingBytes = remainingBytes - currBytesToRead;
  12. int numRead = fread(buffer, sizeof(char), currBytesToRead, file);
  13. if (numRead ! = currBytesToRead) // return Error
  14. send(sockfd, buffer, numRead,0) // meaning even if buffer is CHUNK = 100, and I stored only 6 byes... it will send the buffer and read only 6? or it will read all?
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement