title: Java, xSocket - frames divided into two parts - how read?
body: <p>I have a device that is sending data frames with bytes in one connection. First it sends Hello Frame, to which I respond by ACK, then it sends not fixed-length data frame. And there is a problem. That data frame sometimes is divided into two parts.</p>
  <p>For example:</p>
  <blockquote>
  <p>00 00 00 00 00 00 04 cf 08 09 (and next 234 bytes)</p>
  <p>(994 bytes and last:) 09 00 00 ab 9b</p>
  </blockquote>
  <p>The first 4 bytes in first part are &quot;Preamble&quot;, next 4 bytes are Data Field Length, next one byte of &quot;number of data&quot;, then are data bytes. In second part are data bytes too, followed by one byte of &quot;number of data&quot;, and 4 bytes of CRC-16.</p>
  <p>And this is one example. Another example is divided into two parts too, but in another place:</p>
  <blockquote>
  <p>00 00 00 00 00 00 04 cf 08 09 (and next 1230 bytes)</p>
  <p>00 ab 9b</p>
  </blockquote>
  <p>This is the same frame, but divided in another place...</p>
  <p>And my question is: <strong>How can I read full frame of data?</strong> What approach will be the best? I'm using <a href="http://xsocket.org/" rel="nofollow noreferrer">xSocket</a></p>