title: Using async_read and asio::transfer_exactly (non-Boost Asio)
body: <p>I use non-Boost Asio in asynchronous way. I send data via network in packages which have format like this:</p>
  
  <ul>
  <li>size of package: uint64</li>
  <li>body package: uchar * (size of package)</li>
  </ul>
  
  <p>So when I want to receive package firstly I wait for package size using <strong>asio::transfer_exactly</strong> helper:</p>
  
  <pre><code>asio::async_read(socket, buffer, asio::transfer_exactly(sizeof(uint64_t)), handler);
  </code></pre>
  
  <p>Handler signature looks like this:</p>
  
  <pre><code>void handler(const asio::error_code&amp; error, std::size_t bytes_transferred);
  </code></pre>
  
  <p>But sometimes this handler is executing with <em>bytes_transferred = 0</em> (<em>error</em> doesn't contain any errors) and <em>buffer</em> doesn't contain necessary data (size of package). After that further transmission hangs.</p>
  
  <p>There are no other reading operations from socket, so <em>async_read</em> is calling exclusive.</p>
  
  <p>What can be reason of this behavior? </p>