Using the ZMQ Interface

What to send over ZMQ

PhysioLabXR uses subscriber-publisher sockets for ZMQ streams, because this pattern is more scalable when the cardinality of data is high and less error-prone in case of either the publisher or subscriber process crashes.

Unlike LSL, ZMQ is a messaging library for general use. We define a specific message format for PhysioLabXR to use. When you are creating a ZMQ data source, make sure that you are sending the data in one of the following forms:

  1. A frame containing two parts: the topic name, and the data. The topic name must be a string, and must match the stream name you set when adding the stream. It is necessary for ZMQ to route the message for subscriber-publisher sockets you have multiple ZMQ publisher socket connected to the same socket but publishing to different topics.

  2. A frame containing three parts: the topic name, a timestamp, and the data. The timestamp must be 8-byte (64-bit) double or 4-byte (32-bit) float, indicating when the data was acquired. You can set the timestamp to any value that suits your application. Refer to this page for more information on time.

For an detailed example on how to create a ZMQ data source, see write your ZMQ data source.

Port numbers

When choosing ports for ZMQ sockets, it is important to note that some ports are reserved for system use, and should not be used. For example, ports 0-1023 are typically reserved for system use. Also, some ports are reserved for specific applications. For example, port 80 is reserved for HTTP.

Reversed ports

some ports are reserved by PhysioLabXR. These ports are listed below:

Port

Used by

8000-8100

scripting

9980-9990

replay

Default ports

When creating ZMQ streams from Replay and Scripting, their port numbers are chosen from this list. You can always change these ports in the user interface.

Starting port number

Used by

11000

scripting outputs

10000

replay streams

ZMQ Data types

The ZMQ interface supports the following data types:

uint8, uint16, uint32, uint64, int8, int16, int32, int64, float16, float32, float64