We’ve already seen how to create a simple socket server in Python, but sometimes we need to handle multiple incoming requests simultaneously, that require processor-heavy computation from the server. That’s what a threaded socket server can achieve.
The ESP8266 is an amazing microcontroller that includes a Wifi chip, for a very low price (about $15 for two on Amazon). It offers enough resources to make it the ideal microcontroller choice for most Internet of Things projects. There are several ways to program it, including but not limited to, pseudo-C++ with the Arduino IDE, LUA scripts or MicroPython. In this tutorial we will learn how to set up the ESP8266 with a MicroPython firmware, making it possible to run MictoPython scripts.
Sockets are one of the most commonly used communication tools on computers, but they can be hard to understand at first. If you break it down however, it’s easy to understand how to use them. In this tutorial we’re going to learn how to implement a simple socket server in Python, that will accept a single client connection.
In this tutorial we will focus on logging keyboard events using the Pynput library in Python. I have a Raspberry Pi that I use without a keyboard or mouse, and that is plugged in to my TV. As I mentioned in this tutorial on xdotool, my end goal is to play old games with RetroPie. The only problem is that it’s impossible to control the games over SSH. One possible solution that I found, is to use my laptop to send keyboard events to the Rasperry Pi’s OS.