<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:Arial,Helvetica,sans-serif">On Tue, Jul 14, 2020 at 11:44 PM Papa Tana <<a href="mailto:papa.tana101@gmail.com">papa.tana101@gmail.com</a>> wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">                                        << _:8, Length1:8, Rest1/binary >> = Data,<br>
                                        NumberOfOctets1 = Length1*8,                                    <br>
                                        << _:8, _:8, Content1:NumberOfOctets1, Rest11/binary>> = Rest1,<br>
                                        {ok, <<Header:8,Length1:8,Content1:NumberOfOctets1>>, Rest11};<br>
</blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">There are two problems here you are running into:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">First, you split Data into a header, a length and the rest. But then you split Rest1 again, skipping the header and length. So you are skipping twice over the header and the length. You need to remove `_:8, _:8` because you already stripped that off when you hand in Rest1.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The other problem is that when you write `Content1:NumberOfOctets1` Erlang defaults that to an integer, but you probably want a binary (and they default to a multiple of 8 octet size, so you could write `Content1:Length1/binary`.</div><br></div></div></div>