I have a string that was sent over a network and arrived on my server as a Buffer. It has been formatted to my own custom protocol (in theory, haven't implemented yet). I wanted to use the first n bytes for a string that will identify the protocol.
I have done:
data.toString('utf8');
on the whole buffer but that just gives me the whole packet as a string which is not what I want to achieve.
When the message is recieved, how do I convert a subset of the bytes into a string?
Thanks in advance