I'm setting up a websocket server to connect with a web browser, while reading the Specification (RFC 6455) for websocket frame exchange I came across these values that are supposed to represent a 4bit op code, they look like this:
%x0 %x1 %x2 ..... %xA %xB .... %xF
I know that %x0 = 0000 and %x1 = 0001
I'd like to know what these values are called and how to convert them to bits. Thank you.
These %xN
representations use a single hexadecimal digit to describe a four-bit binary number.
The possible values of a four-bit binary number range from 0 (0000
) to 15 (1111
), so each value can be expressed as a hexadecimal digit:
0 %x0
1 %x1
10 %x2
11 %x3
100 %x4
101 %x5
110 %x6
111 %x7
1000 %x8
1001 %x9
1010 %xA
1011 %xB
1100 %xC
1101 %xD
1110 %xE
1111 %xF