Reputation: 11972
I have a buffer containing the following:
04 01 0c ea c0 a8 00 01 00
The 3rd and 4th bytes (0x0c
0xea
) form a port number (3306), but how can I take these bytes and transform them into this integer (3306)?
Upvotes: 1
Views: 3001
Reputation: 163232
I believe you want buf.readInt16LE()
.
http://nodejs.org/api/buffer.html#buffer_buf_readint16le_offset_noassert
Upvotes: 4