UDP Image Protocol

Electro implements dynamic images using a simple UDP-based message protocol. A dynamic image is created when create_image is called with a numeric port number. A socket is opened on this port and incoming datagrams are read.

An image datagram consists of a 14-byte header followed by image data. The header is in network byte order and is described below. The image data are byte-wise and thus byte-order-independant. A datagram may specify one or more image scan lines per datagram

struct header
    int   code;
    short r;
    short n;
    short w;
    short h;

A 32-bit value giving the FOURCC code of the incoming image data. The following FOURCC codes are supported.


The row number of the first scan line given by this datagram.


The total number of scan lines given by this datagram.

w, h

The width and height of the image as a whole. Electro uses these values to determine image size. A dynamic image has a default size of 128×128. If a datagram gives width and height values that are not equal to the current image size then the image will be flushed and reallocated. The resulting contents of the image are undefined.