I have a special place in my heart for Telnet. For a (short) while I was blissfully unaware of Putty or Netcat, so Telnet was my go-to socketing tool. Now I've moved on to writing my own tools, I realize how awful Telnet really is (but in a sort of cute way).
Telnet still gets used for a variety of machines (including Cisco routers) by default, so it's good to learn of its existence and vulnerabilities. We will set up a Telnet server, and I'll give you the code for a simple client that you can customize to fit a variety of scenarios.
We're going to use an established solution to set up the Telnet functionality for us in Python. This solution is called Miniboa and can be found at https://code.google.com/p/miniboa/. What's great about Miniboa is that it does all the hard work for you, and as long as you can read/write Python (which you can or you'd have stopped reading by now), then it's pretty darn simple to get a Telnet solution up and running.