I suggest you check all the returns if things go wrong.
This will happen in every app you write, so learning to diagnose these types of issues is vital.
Tell us what this returns (not complied, off the top of my head...)
Code:
int iRet=0,iErr=0;
iRet=WriteFile(f,Buffer,amount,&written,0);
//WriteFile returns 0 for success
if(iRet)
{
//error occured in WriteFile()
iErr=GetLastError();
printf("WriteFile failed with %d and GLE returned %d.",iRet,iErr);
}
//but we should also check if the right amount was writen to file.
else if(amount!=written)
{
//WriteFile did not write the correct amount to the file
iErr=GetLastError();
printf("WriteFile wrote wrong amount %d of %d [GLE returned %d].",amount,written,iErr);
}
//else success
EDIT:
I also wonder what will happen if amount == sizeof(Buffer) as you will not have a null terminator.
Probably nothing in a complier (and 99.99% of the time in release) but I would be inclined to use (sizeof(Buffer)-1) in recv()