TCP-Server that listens on a specified port for TCP-Connections. Every request sent to the server has to be one of the special commands described later on or a string of 0s and 1s each specifying a dot to be turned on or off respectively. For instance, to display the letter ‘T’ on a 4x3 display of this form


the following request must be sent to the server: 111101100110.

A simple command line client like nc can send this request to ‘server’ listening on port 10101:

$ echo 111101100110 | nc server 10101

If the request contains the string ‘SIZE’ (ignoring case), the server will respond with the dimensions of the display (width x height).

Lets start a server. Here we use a thread in order to be able to run the client afterwards. In practice the server will run on a different platform and can be started directly.

>>> import net
>>> import displayprovider
>>> import threading
>>> ds = net.DisplayServer(displayprovider.DisplayBase())
>>> th = threading.Thread(target=ds.start)
>>> th.setDaemon(True)
>>> th.start()
Starting server for dimension 4 x 3 on at port 10101

Now we can start a client and send some pixels to the server.

>>> cl = net.RemoteDisplay(host="")
Remote display will send data to on port 10101
>>> cl.px(1, 1, True)
>>> cl.px(2, 3, True)
Listening on at port 10101
received 12 bytes

The output lines after show() are coming from the server.

class net.DisplayServer(display)[source]
start(host='', port=10101)[source]
class net.RemoteDisplay(host='', port=10101, width=28, height=13)[source]

Remote class to connect with a running display server.

px(x, y, val)[source]