REDnet dispatcher
Introduction
The dispatcher is a command line administration tool which gives information about every registered Rednet peer accessible through the network.
Note:
The dispatcher application can be found in the same directory as any other REDsdk binaries for your platform.
A relay between applications and peers
The main purpose of the dispatcher is to register the IP addresses of all the running peers over the network. When a client application connects to it and ask for a peer URL, the dispatcher replies with the first available peer amongst the registered ones. Hence, client applications only have to know the dispatcher IP address and not those of the peers: the dispatcher acts as a relay between client applications and Rednet peers.

The Rednet dispatcher acts as a relay between client applications and Rednet peers. Here in orange are peers which are busy and in green those which are available. The dispatcher answers to the web browser request by returning the IP of the third peer which is the first available one.
Peers management by the dispatcher is transparent to the Rednet-based application developer. The only task left to the developer is the registration of his application to the dispatcher (see Registration of peers). After that, peers and dispatcher communicate together to keep an up-to-date list of living peers over the network along with their status (ready or busy).
If a peer disconnects (following a user action or a network error), the dispatcher reacts by removing the peer from its list. Inversely, if the dispatcher shuts down, all the connected peers are informed and can ask their users what to do.
Because peers can accept any number of connections, the status of a peer is completed with an information about the peer work load. Hence a peer is ready as long as its work load is less than 100%. As soon as it gets as high as 100%, the peer appears as busy. The dispatcher won't send the URL of a busy peer anymore until it gets ready again.
Settings for the dispatcher are read from the Dispatcher.ini file located in the same directory than the program itself. If the file is not present or incomplete, default values are used instead.
There are 4 main settings:
- port: the communication port is used to communicate with the dispatcher. Default value if 18000.
- max_connections: maximum simultaneous connections allowed to the dispatcher. There can't be more
clients using your Rednet services than that value. Default value is 0 (meaning unlimited number of connections).
- version: version of the dispatcher. May be useful to filter older or newer peers from the network.
Default value is 1.
- path: path to the dispatcher resources like web pages, icons and scripts.
Here is an example of a valid Dispatcher.ini file:
[options]
port=8080
max_connections=1024
version=1
path=../Resources/REDNet/www
The same settings are available through the command line using the same labels. Values set with the command line overrides those defined in the Dispatcher.ini file.
For example, you can override the communication port number value by typing: dispatcher.exe -port 1234.
Registration of peers
You have to manually register the peers to the dispatcher. To do that, the dispatcher must be run first. Then, every peer is run with the address of the dispatcher passed to the Rednet API (RNET::IPeer::Start). The peer automatically tries to connect to the dispatcher and get registered to it if everything goes well. More on this in the tutorial Registering to the dispatcher.
You can choose to not use the dispatcher. In that case, the client application must know the exact IP addresses of the peers in order to access to them directly.
Get a peer URL from the dispatcher
Once connected to the dispatcher, a Rednet-based application (or a HTML 5 web page) can asks for the URL to a registered peer. This is accomplished by sending the 'get_server_url' string to the dispatcher (more in the Server sharing tutorial).
The dispatcher then answers with a URL to the registered peer which has the lowest work load. If none is available (because all peers are busy or no peer is registered), it answers with the 'none' string. Otherwise, a valid string containing the URL to a peer is returned.
Dispatcher monitoring
Dispatcher settings can be modified dynamically from anywhere using a web browser. Type [dispatcher_ip:port]/dispatcher.cgi in the address bar of a web browser to open the dispatcher settings and monitoring interface (where [dispatcher_ip:port] is the IP address followed by the communication port of the dispatcher). This interface displays the current settings of the dispatcher and the list of registered peers along with their current status.

Dispatcher settings can be accessed from any web browser.
Each time the Apply changes button is pressed, the dispatcher is stopped and restarted. New settings values are automatically saved to the Dispatcher.ini file. All opened connections are lost and must be initiated again by the peers.
Very basic statistics about connections can also be displayed by clicking the Display button at the bottom of the page.

The dispatcher can display rough statistics about number of connections over days.
![]() |