Binary Framing
Unix domain sockets are raw byte streams with no built-in message boundaries. To pull individual market-data messages out of the stream, the Market Data Adapter prefixes each one with a small header. This page documents that framing.
Framing format
Each message is prefixed with a 32-bit integer (big-endian):
- Most significant bit: message type.
0= binary.1= text.
- Remaining 31 bits: size of the message data, excluding the 4-byte prefix.
- Byte order: big-endian.
Text and binary are not two protocols. The protocol carried over a domain socket is the same one carried over a WebSocket, and the type bit exists only to mimic what WebSocket gives you for free: a frame that already knows whether it holds text or binary. The bit tells you how to decode the payload, JSON for text and SBE for binary, not which protocol you are speaking.
Reading messages
The Market Data Adapter uses the same prefix when sending. To read a stream:
- Read the first 4 bytes to get the type and size of the next message.
- Read that many bytes of message data.
- Repeat.
See Also
- Accessing Data. How to connect and subscribe.
- Protocol. Market data protocol specification.