title: boost::asio async_read guarantee all bytes are read
body: <p>I have a server that receives a compressed string (compressed with zlib) from a client, and I was using <code>async_receive</code> from the <code>boost::asio</code> library to receive this string, it turns out however that there is no guarantee that all bytes will be received, so I now have to change it to <code>async_read</code>.  The problem I face is that the size of the bytes received is variable, so I am not sure how to use <code>async_read</code> without knowing the number of bytes to be received.  With the <code>async_receive</code> I just have a <code>boost::array&lt;char, 1024&gt;</code>, however this is a buffer that is not necessarily filled completely.</p>
  
  <p>I wondered if anyone can suggest a solution where I can use async_read even though I do not know the number of bytes to be received in advance?</p>
  
  <pre><code>void tcp_connection::start(boost::shared_ptr&lt;ResolverQueueHandler&gt; queue_handler)
  {
      if (!_queue_handler.get())
          _queue_handler = queue_handler;
  
      std::fill(buff.begin(), buff.end(), 0);
  
      //socket_.async_receive(boost::asio::buffer(buff), boost::bind(&amp;tcp_connection::handle_read, shared_from_this(), boost::asio::placeholders::error));
      boost::asio::async_read(socket_, boost::asio::buffer(buff), boost::bind(&amp;tcp_connection::handle_read, shared_from_this(), boost::asio::placeholders::error));
  }
  </code></pre>
  
  <p><code>buff</code> is a <code>boost::array&lt;char, 1024&gt;</code></p>