title: Unable to send large files using tcp socket from Java client to C++ server
body: <p>I'm writing a C++ that has a feature of receiving file via socket from a Java client.
  The file's size I'm trying to send is 510KB, but the server only receives 46KB and then gets stuck "waiting" for more bytes.</p>
  
  <p>This is the server code: (I tried to receive 510KB at once, but the server got stuck, so I tried also to receive 64KB each iteration and again, the server got stuck).</p>
  
  <pre><code>int bytes_to_receive;
  size_t length;
  while(file_length &gt; 0)
  {
      if(file_length &gt;= 65536)
          bytes_to_receive = 65536;
      else
          bytes_to_receive = file_length;
      char buf5[bytes_to_receive];
      length = 0;
      while( length &lt; bytes_to_receive )
          length += socket.read_some(boost::asio::buffer(&amp;buf5[length], bytes_to_receive - length), error);
  
      string temp(buf5);
      file_parts.push_back(temp);
      file_length -= bytes_to_receive;
  }
  
  string file("");
  vector&lt;string&gt;::const_iterator it;
  for(it = file_parts.begin(); it != file_parts.end(); ++it)
  {
      file += *it;
  }
  </code></pre>
  
  <p>The Java client load the file to a string, and then sends the string using</p>
  
  <pre><code>writeBytes
  </code></pre>
  
  <p>Note: When sending a 1KB file everything works.</p>
  
  <p>Why does this happens and how can I fix it? Any help would be highly appreciated. </p>
  
  <p>Edit: any other way of receiving large data using boost would be appreciated.</p>