Showing posts fromcoding

C++ Wrapper for Socket

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 consisten

Read More

Common Mistakes

### 1: using namespace Every new developer that comes to C++ always starts writing code like this: myfirstprog.cpp ```c #include <iostream> using namespace std; ``` It seems reasonable and every

Read More

Control Flow

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 (Condi

Read More

Functions

### Usage 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

Read More

Hello World

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

Read More

Memory Resizing

So I never really considered why the resize of vector used a constant expansion of 1.5 or 2 (in some popular implementations). That was until I did my previous article Xseries ["Vector"]({{config.sit

Read More

Nisse - Origins of a Server Library

# [Nisse](https://github.com/Loki-Astari/Nisse) [Nisse](https://github.com/Loki-Astari/Nisse) is a C++ library that simplifies the creation of C++ web-based [applications](https://github.com/Loki-As

Read More

A Web Server

# [Nisse](https://github.com/Loki-Astari/Nisse) Describing all aspects of Nisse in a single article would be complex and overwhelming. I want to start with a beginner’s perspective and address a rea

Read More

C++ Sockets

# [Nisse](https://github.com/Loki-Astari/Nisse) In the previous article "A Web Server," I created the simplest web server possible. This article covers the next stage by addressing the issues relat

Read More

SSL Certificates

# [Nisse](https://github.com/Loki-Astari/Nisse) In the previous article, "C++ Sockets," I mentioned that thors-mongo had built-in support for SLL connections but glossed over the details. In this ar

Read More

Multi Threading

# [Nisse](https://github.com/Loki-Astari/Nisse) In the first three articles, we created a very basic Web Server. A major issue with this simplistic server is that it can only handle connections seri

Read More

Smart-Pointer - Constructors

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 a

Read More

Smart-Pointer - Shared Pointer

So in [the previous article](https://lokiastari.com/posts/Smart-Pointer-UniquePointer) I covered a basic `unique` pointer where the smart pointer retained sole ownership of the pointer. The other comm

Read More

Smart-Pointer - Unique Pointer

On [codereview.stackexchange.com](https://codereview.stackexchange.com) in the C++ tag it seems that it is a write of passage to implement your own version of a smart pointer. A quick search brings up

Read More

Socket Programming in C

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 pro

Read More

Socket Protocols

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 commu

Read More

Socket Read/Write

## 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

Read More

Variables

## Variables 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 ma

Read More

Vector - Resize

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

Read More

Vector - Resource Management Allocation

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

Read More

Vector - Resource Management Copy Swap

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`. Unl

Read More

Vector - Simple Optimizations

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 manuall

Read More

Vector - The Other Stuff

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 cons

Read More

Want to set up WordPress to write about Programming

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 abo

Read More