Matching N digits using binaries

I have a packet coming from a socket which is composed by two subsections, the first composed by 4 numerical digits and the latter composed by 16 alphanumerica digits.

How can I bind the packet coming from the socket using binaries and pattern matching?

For example if I receive:


I would like to obtain:

Packet1 = 1234
Packet2 = "th58i4kr04o3"


You can do this by using Erlang bit syntax and binary pattern matching:

<<A:4/binary, Rest/binary>> = <<"1234th58i4kr04o3">>, 
Packet1 = binary_to_integer(A), 
Packet2 = binary_to_list(Rest).

Need Your Help

iOS: Unable to play my sounds when silent mode on

iphone objective-c ios audio audiotoolbox

So I've already gone through most of the relevant question on SO that I could find, yet I still can't get my audio playing while silent. I believe that it's probably a small error I'm making.