Archive for March, 2010

What’s Wrong With This Code?

March 29, 2010


I meant to include this in my post about Building a DNS Resolver, as it is a small, yet significant bug that took me a little while to find. What the code should be doing, is reading a string from a file (where all strings in the file are guaranteed to be 255 characters or less), then pushing that string into a Queue. So before you jump to the whole article, can you see what’s wrong with the code?

(more…)

ASCII Hangman

March 29, 2010

Back in late 2007 I was fresh out of my freshman year of a computer science degree, and thought I knew C++ well enough to build another game. The “Haunted House” game took forever to build and was full of bugs at first, but that was a full semester of classes ago. Now I was ready to make another game, also I was bored and wanted to stay sharp, so I built an ASCII-art Hangman game.

(Update June 2013: The original source code is now available on GitHub! Feel free to download and play with it!)

(more…)

Building a DNS Resolver

March 25, 2010

If you’ve ever had to turn a hostname into an IP address or the other way around in your C/C++ code, you probably called either gethostbyname() or gethostbyaddr(), and never thought twice about how those functions work. Well, they’re more complex than you might think, and they’re slow.

(more…)