sizeof returns the size in bytes of the buffer variable (not the value of the contents of said variable) which is 4 because buffer is a 4-byte pointer variable. What you probably want is to use the value in the variable
size again in your loop instead:
Code:
int size = atoi(data2);
char* buffer;
buffer = new char[size];
unsigned int k = 0;
do {
if (recv(h,&buffer[k],1,0)==SOCKET_ERROR) {
addlog("retlinehttp(): recv() Failed! %d", WSAGetLastError());
return -2;
}
fwrite (&buffer[k] , 1 , 1 , file);
k++;
} while (k < size);