title: Receving TCP/IP completely before processing it. How to know if total data sent has been received?
body: <p>Currently I am receiving data synchronously in the following manner</p>
  
  <pre><code>             boost::array&lt;char, 2000&gt; buf;
               while(true)
              {
                  std::string dt;
                  size_t len = connect_sock-&gt;receive(boost::asio::buffer(buf, 3000));
                  std::copy(buf.begin(), buf.begin()+len, std::back_inserter(dt));
                  std::cout &lt;&lt; dt;
              }
  </code></pre>
  
  <p>My question is whether this method is efficient enough to receive data that exceed the buffer size . Is there any way that I could know exactly how much data is available so that I could adjust the buffer size accordingly ? (The reason for this is that my server sends a particular response to a request that needs to be processed only when an entire response has been stored in a string variable.</p>