03 July 2024
MessageLib - a (WIP) python library to simplify making networked programs
I find it annoying how many of my A level students find their projects limited by the practical impossibility of adding networking features. However, the truth is that dealing with sockets directly is a pain - especially if you want to use UDP-broadcast server discovery as well as TCP streams.
Me writing networking code for the students' projects would be absurd though - they'd learn next to nothing and would likely end up using my code verbatim if they wanted to implement networking features in their NEA. That is definitely not a situation I want to be in.
It occurred to me that there is room for a wrapper library which handles the low-level socket things whilst still leaving it up to the student to design their own protocol for their specific application.
This is where messagelib comes in.
It makes writing the python code to run a server relatively trivial (see the echoserver example) and even a client which discovers servers and selects one to connect to is not horrendous.
I intend to put it in front of some A level students in the autumn term to see if they can make some simple network applications. If they reference it properly, they could even use it in their NEA and still get complexity marks for designing their own application protocol to sit on top of it.
However, it is still a work in progress. The code is half designed and half hacked-together - I've got a way to go before I'm properly happy with it. Plus, it is not yet rigorously tested; I have tested the echo-server with multiple clients and servers on different machines across a single subnet, but I am sure there are bugs and design flaws still to uncover.
It's distributed under the MIT licence, which (as I understand it) allows you to use it however you want as long as you include the copyright notice if you distribute it.
If you use it, please let me know how you get on! I would love feedback so I can make it as widely usable as possible.
Discussion
Please login to post a comment