c - File Download - WinSock -
after downloading exe file server via winsock in c. error:

here code use write bytes read file:
while (recv(mysock, buf, filebuffer, 0) > 0) { writefile(hfile, buf, sizeof(buf), &bytes, null); } here variable definitions used:
#define filebuffer 2048 char buf[2048] anyone know how can fix this, or problem is?
you're assuming recv returns full buffer every time, there's no guarantee (when testing > 0) returns more 1 byte. need use result of recv amount of data write file.
Comments
Post a Comment