title: Should send() and recv() buffer size be as big as possible?
body: <p>I'm sending a .mp3 file (.jpg and other extensions as well, size between 1K to 50MB) using winsock over http. The client sends file and the server receives the file .<br>
  I have serveral questions:</p>
  
  <ol>
  <li><p>Should send() buffer size and recv() buffer size be the same? </p></li>
  <li><p>What size should I choose, fixed size or a size big enough to contain all data? </p></li>
  </ol>
  
  <p>Here comes the code. </p>
  
  <p>Client:  </p>
  
  <pre><code>... //POST /index.html HTTP/1.1 and so on
  
  sprintf_s(header, "%sContent-Length: %d\r\n", header, sizeof(szFileData ));
  sprintf_s(header, "%s%s\r\n", header , szFileData );  
  
  ... //Content-Disposition: form-data; name=\"submit\" and so on
  
  while(send(sock,  header, strlen(header), 0) == SOCKET_ERROR)
  {
      Sleep(1000);
  }
  </code></pre>
  
  <p>Server： </p>
  
  <pre><code>recv(sock, recvbuf , 4096 , 0);  //neither strlen(recvbuf) nor 4096 works
  ...//extract file name, content and so on
  
  FILE *pFile;
  pFile = fopen ( filename , "wb" );
  if ( fwrite(filedata, sizeof(filedata), 1,  pfile) != 1)
  {
      MessageBox(NULL, "Failed!", "MSG", MB_OK);
  }
  </code></pre>
  
  <p>I get a result that either is empty or loses some content. </p>