Sprinkle some coding goodness..

So back about a year ago, I was writing a terminal application similar to PuTTy and was looking for a good SSH l ibrary to use. I happened upon two libraries that looked like they'd fit the bill: libssh2 and libssh.

After digging in a bit more, I found out that libssh didn't quite work on Windows and they were looking for someone to maintain it or join the team and handle the windows part of it. Cool. So I sent an email and tried to see if I could join them... never got any answer. After some research I found out that libssh2 would be a bit better since it had the added benifit of working cross-platform and my app was going to be Qt4 based.

After getting my app up and running with libssh2 and digging into various aspects of the code to see how things worked and why some things didn't, I ended up joining their team and trying my hand at some bug fixing. Hopefully I was able to make a few good bug fix contributions, but to be quite honest, I didn't have a clear understanding of SSH as a whole. The use of "gotos" in the code and the way they were keeping state just seemed klunky to me. Looking back on it after knowing what I know now about C-libraries, their approach was just fine, but their overall design limited what is truly possible. Libssh2 was using blocking sockets at the time; they have since added support for non-blocking sockets which should help performance a little. But still, with a single threaded lib, you can only do one thing at a time and anytime the lib is using the CPU, the end-user's application sits blocked.

One of their biggest drawbacks (in my opinion) was that the library was single-threaded. So your user app would do some processing and then decide to get data from the lib. Now the lib takes control and does a bunch of polling/processing, all while your user app is blocked waiting for the lib to finish. In a multi-core world, this is a horrible waste of CPU resources.

So about November of 2008, I sat down and started working out a basic API and a decent multi-threaded design that would be geared towards efficiency and throughput. I decided that I'd wrap up the parts of the library that were tedious for beginners and make a lib that would handle everything that it could and take advantage of any available cores.

Here I am a year later releasing a pre-alpha version of my library. Performance is definitely up where I hoped it would be ;p I'm a good deal faster than my other two competitor libraries. I'll throw some benchmarks out at a later date when I can test with the latest code from various libs.

Woot! My lib is out in the world!