On some platforms (e.g. Windows), the Stream IO means the buffer is not completely filled on the first read. The behaviour should be modified to check if the buffer is partially filled for header or frame and allow the buffer to fill completely before processing it.