I’ve always enjoyed working with Tornado Web, the python web framework that is centered around the idea of using non-blocking sockets. It is a very versatile framework for working with asynchronous streams and I’ve used it to write a number of applications, including proxy servers, media streamers, and even BitTorrent clients. But tornado is noticably lacking in UDP support. This is fine, of course. After all, it is an HTTP library.
When you would like to do some non-blocking UDP stuff using tornado, all you need to do is use this custom “UDPStream” class that I wrote. It acts a lot like tornado’s IOStream class.
The basic use of this class is illustrated in the following code snippet.