Loki Astari

Thoughts of a former code monkey.

Socket Protocols

| Comments

In the previous articles I have used a very simplistic protocol. In real world situations this simple protocol is not sufficient. To provide a more robust connection between client and server a communications protocol is required so that we can vali…more

C++ Wrapper for Socket

| Comments

The last two articles examined the "C Socket" interface that is provided by OS. In this article I wrap this functionality in a very simple C++ class to provide guaranteed closing and apply a consistent exception strategy. The first step is to rewrite…more

Socket Read/Write

| Comments

Checking read/write success

The read() and write() command can fail in a couple of ways but can also succeed without reading/writing all the data, a common mistake is not to check the amount of data read/written from/to a stream. Interesting…more

Socket Programming in C

| Comments

Building a simple client/server application is the common first internet based applications developers attempt. These applications are built on top of the socket communication library, but socket programming in C++ is not obvious as there are no sta…more

Vector - The Other Stuff

| Comments

So the C++ standard specifies a set of requirements for containers. Very few requirements are specified in terms of containers so adhering to these exactly is not required (unless you want to be considered for the standard). But they provide an insi…more

Vector - Simple Optimizations

| Comments

So now that we have used std::is_nothrow_move_constructible we can also look at a couple of other types available in the template utility library.

Optimized Destruction

Since we have to manually call the destructor on all objects in the contai…more

Vector - Resize

| Comments

Because resizing a vector is expensive; the std::vector class uses exponential growth to minimize the number of times that the vector is resized: a technique we replicate in this version. But every now and then you still need to resize the internal…more

Vector - Resource Management Copy Swap

| Comments

In the previous article I went over basic allocation for a Vector like class. In this article I want to put some detail around the copy assignment operator and resizing the underlying Vector. Unlike the other methods previously discussed these m…more

Vector - Resource Management Allocation

| Comments

A lot of new developers to C++ attempt to build a Vector like container as a learning processes. Getting a simple version of this working for POD types (like int) is not that complicated. The next step in getting this working for arbitrary data ty…more

Smart-Pointer - Constructors

| Comments

In this article we examine constructors that are often missed or overlooked. This article looks at the use cases for these constructors and explains why the added functionality provides a meaningful addition in relation to smart pointers.


Nearly New Year/New Resolution

| Comments

New Year/New Resolution

They say you can only get better at something by doing it.

I want to get better at writing articles about what I do so I better keep trying. Reading the articles I wrote last year (with the hindsight of a year) it seems my…more

Control Flow

| Comments

So far we have demonstrated basic programs that just do a single task without making any decisions. Most (all but the most trivial) programming languages provide constructs for decision making (Conditional Branching).

C++ provides two forms of bran…more

Switching to OctoPress

| Comments

Switching to OctoPress and Github

I have not blogged much, until recently, so I am not an HTML/CSS/Javascript expert. Thus layout, or layout during writing an article, is not of supreme importance for me. I expect the framework to handle that al…more


| Comments


All C++ applications must have at least one function; this is called main(). Additionally, you can have user defined functions that encapsulate individual tasks, thus allowing the code to be cleaner and easier to read. Therefore, this is…more


| Comments


In most programming languages you have the concept of variables. These are simply named objects that hold a value (more formerly refereed to as state). By manipulating a variable you manipulate the state of the object that the variable…more

Common Mistakes

| Comments

1: using namespace

Every new developer that comes to C++ always starts writing code like this:


#include <iostream>

using namespace std;

It seems reasonable and every book on learning C++ out there perpetrates the sam…more

Want to set up WordPress to write about Programming

| Comments

Setting up WordPress to display syntax highlighted code was a struggle due to different plugins that don’t all seem to work together, the different types of editor, etc. I don’t want to learn all about WordPress. I just want to write some simple art…more

Hello World

| Comments

This is the first article in the series
OK. Lets do this.

I keep trying to think about something big and interesting to write about. But that is just not working. All my time is spent trying to think of the blockbuster idea; which just gets in the w…more

Interviews Processes

| Comments

We (SEOmoz.org) have been doing a lot of interviews for new engineers lately. I have been asked to help out trying to find the great new team members from the hordes of applicants (luckily we have a great team pre-screening app…more