Sunday, 11 November 2012

Raspberry Pi Network Programming

I was recently asked to create a simple networking program to demonstrate to school children during a Science and Technology open day. We used Raspberry Pi computers and I created a simple Instant Messenger program in Python using the Socket interface, which is quite easy. For simplicity sake I had a separate sender program and a receiver program which listens for incoming connections. This is the code for the receiver:

The code for the sender looks like this:
We ran these programs on 10 Raspberries connected together in an cabled LAN. To make this work the Raspberries needed static IP addresses. This is done by editing the interfaces configuration file.

The program works fairly well, although the receiver can only accept one connection at a time. The main aim of the program was to create something simple that was relatively easy to understand. The children enjoyed playing with the program and manged to send and receive messages but didn't really have time to get to understand how the program works.