Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define CHUNK 100
- void ReadAndSendFile(File *file, int totalFileSize , int sockfd)
- {
- char buffer[CHUNK] = {0};
- int remainingBytes = totalFileSize;
- int currBytesToRead = 0;
- while(remainingBytes > 0)
- {
- currBytesToRead = minimum(remainingBytes,CHUNK);
- remainingBytes = remainingBytes - currBytesToRead;
- int numRead = fread(buffer, sizeof(char), currBytesToRead, file);
- if (numRead ! = currBytesToRead) // return Error
- 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?
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement