12345678910111213141516171819202122232425262728293031 |
- #include "stdafx.h"
- #include <winsock2.h>
- #include "constdef.h"
- bool sendContent(SOCKET s, char* filePath)
- {
- char buf[MAXSIZE] = {'\0'};
- FILE* filePtr;
- fopen_s(&filePtr, filePath, "rb");
- if(filePtr == NULL)
- {
- //printf("Failed to open the file\n");
- return false;
- }
- else
- {
- int sendCount;
- while(!feof(filePtr))
- {
- sendCount = fread(buf,sizeof(char), MAXSIZE, filePtr);
- send(s, buf, sendCount, 0);
- if(ferror(filePtr))
- {
- //printf("File read error\n");
- return false;
- }
- }
- }
- fclose(filePtr);
- return true;
- }
|