c - File Download - WinSock -


after downloading exe file server via winsock in c. error:

image

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

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -