Table of Contents

Program architecture

Client

Reads keystrokes from server. Creates screenshots, detects changes in them and sends changed tiles (128x128px by default) to the server.

Two threads: GUI thread and ClientWorker, communicating with queues.

ClientWorker thread:

GUI thread:

Server

Displays tiles received from client. Forwards KeyPress and MouseClick events to the client.

Two threads: GUI thread and ServerWorker, communicating with queues.

ServerWorker thread:

GUI thread:

Protocol specification

Datagram format: 4B magic value “0x95400954”, 4B length, 4B type, lengthB-4 payload

Message type 0x02: Client -> Server Rectangle

payload: 2B format, 2B xstart, 2B ystart, 2B width, 2B height, data

format: 0x1 = JPEG

Contains image data to be displayed.

Message type 0x01: Server -> Client Hello

payload: nothing

Message type 0x02: Server -> Client Mouse Event

payload: 2B X, 2B Y, 4B flags

Message type 0x03: Server -> Client Text Input (type 0x3)

payload: text to be typed on the keyboard

Message type 0x04: Server -> Client Force Redraw (type 0x4)

payload: nothing

Forces client to resend all tiles again.

Sources used