The frame header
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-------+-+-------------+-------------------------------+
|F|R|R|R| opcode|M| Payload len | Extended payload length |
|I|S|S|S| (4) |A| (7) | (16/64) |
|N|V|V|V| |S| | (if payload len==126/127) |
| |1|2|3| |K| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
Advertisement
FIN + opcode
FIN=1 marks the last frame of a message. Opcode: 0x1=text, 0x2=binary, 0x8=close, 0x9=ping, 0xA=pong, 0x0=continuation.
Advertisement
Payload length — three sizes
- 0-125: fits in the 7-bit field.
- 126: next 2 bytes = 16-bit length (up to 65535).
- 127: next 8 bytes = 64-bit length.