I`m trying to send binary file using socket.
FILE *file;
char *file_data;
file = fopen(filepath, "rb");
//Allocate memory
file_data=(char *)malloc(fileLen+1);
//Read file contents into buffer
fread(file_data, fileLen, 1, file);
fclose(file);
sent = send(client, file_data, strlen(header)+fileLen, 0);
It works OK, but some files a too large and I want to read a part to buffer, send it, then read the second part, send it and so on.
I tried to get parts using fread and fgets, but i failed =( How to do it correctly?
UPD: the trouble was in reading incoming request from client. I didnt read it. If i do it, nothing bad happens