For my own education, I've set about on an endeavor to reimplement several standard internet protocols. Because there are significant benefits to understanding when you teach a topic yourself, I am writing this next series of blog posts to be informative to whoever may find them.
I intend to recreate the following protocols:
- Telnet
- DNS
- SMTP
- HTTP
- IRC
In doing so, I expect I'll be able to have a firm understanding of each of these protocols and how they work in our real world. Some of these are antiquated, like Telnet, but that doesn't mean that understanding them is useless. Understanding the stepping stones to the protocols we use today, like ssh and sftp, can provide valuable insight into why make the decisions that were made with those protocols.
With each one, my objective is to create a piece of software that will interact with "real" code. As in, I will make a program that you can telnet into and create a program that can telnet into another machine. These will not be pieces of software that are intended to be used in a real-world environment, but rather easy for someone new to the protocol to read and understand. (Basically what I want and why I'm writing these posts.)
Sockets
However, before I dive into those protocols, there is another part of programming history that needs to be covered. Sockets. This part of network programming is old, dating back to 1983, but was so well done and so integral to our world that it remains the backbone of networking.
I became quite good at using sockets during my undergrad years. It started when I wanted to learn how to make a webserver with Python. This search led me to "Twisted" a library or framework (depending on how you use it) for Python. I found a tutorial by Dave Peticolas on an introduction to Twisted and asynchronous programming, which you can find here.
I must apologize to Dave as I never made it past his second part (there are 22). Though at the same time, I must thank him. I'm sure he said this as a minor detail, but this sentence sent me down a path that made me a much better programmer:
If you have never used sockets before, you might read the socket module documentation now, especially the example code towards the end.
At the time, that link pointed to the Python 2.6 implementation of the socket library. I'm a skimming kind of guy, I usually search and skim the python standard library for the information I need, as I believe most of us do. However, I read that article from top to bottom in one sitting (a feat for a person with dyslexia). It's gotten longer now, but if you want to understand how networking programming works, read it. Python so beautifully lays bare all of the intricate facets of network programming in an easy way to use. I made a simple socket client and server as an example.
The sophomore me saw the incredible potential here. I could write anything. I was not restricted to it being Html. I imagined distributed computing, distributed file systems, all sorts of things. All of these already existed, of course, and I did not need to recreate them but didn't stop me from trying. The ideas only were fascinating to me.
I did make a distributed computing system, but I ended up using SQL and not sockets as the backend. The reason being, unfettered freedom is hard to manage. That unfettered freedom is what brings me back to this post. Rather than make everything on my own, I'm going to make what other people have made, the programmer equivalent of painting other painters' paintings. This is one way I hope to become a better programmer.