title: How is this 13 bytes long?
body: <p>Two quotes:</p>
  
  <blockquote>
    <p>All of the remaining messages in the protocol take the form of <code>&lt;length prefix&gt;&lt;message ID&gt;&lt;payload&gt;</code>. The length prefix is a four byte big-endian value. The message ID is a single decimal byte. The payload is message dependent. </p>
  
  <pre><code>request: &lt;len=0013&gt;&lt;id=6&gt;&lt;index&gt;&lt;begin&gt;&lt;length&gt; 
  </code></pre>
    
    <p>The request message is fixed length, and is used to request a block. 
    The payload contains the following information:</p>
    
    <ul>
    <li>index: integer specifying the zero-based piece index</li>
    <li>begin: integer specifying the zero-based byte offset within the piece</li>
    <li>length: integer specifying the requested length. </li>
    </ul>
  </blockquote>
  
  <p>When I write everything it sums up to 5 bytes. Using </p>
  
  <pre><code>ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  byteStream.write( 13 );
  byteStream.write( 6 );
  byteStream.write( index );
  byteStream.write( begin );
  byteStream.write( length );
  
  message = byteStream.toByteArray();
  </code></pre>
  
  <p>EDIT: Sorry i was kind of pissed when i wrote it. its the bittorent protocol.
  Using this <a href="http://wiki.theory.org/BitTorrentSpecification#Peer_wire_protocol_.28TCP.29" rel="nofollow noreferrer">spec</a>.</p>