title: File Download - WinSock
body: <p>After downloading an exe file from my server via WinSock in C. I get this error:</p>
  
  <p><img src="https://i.stack.imgur.com/E69q6.png" alt="image"></p>
  
  <p>Here is the code I use to write the bytes read to the file:</p>
  
  <pre><code>while (recv(mySock, buf, FILEBUFFER, 0) &gt; 0)
  {
       WriteFile(hFile, buf, sizeof(buf), &amp;bytes, NULL);
  }
  </code></pre>
  
  <p>Here are the variable definitions used:</p>
  
  <pre><code>#define FILEBUFFER 2048
  
  CHAR buf[2048]
  </code></pre>
  
  <p>Anyone know how I can fix this, or what the problem is?</p>