Showing posts fromcoding

C++ Wrapper for Socket

The last two articles examined the "C Socket" interface provided by the OS. In this article, I wrap this functionality in a simple C++ class to provide guaranteed closing and apply a consistent except

Read More

Common Mistakes

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

Read More

Control Flow

So far, we have created basic programs that perform a single task without making any decisions. Most (all but the most trivial) programming languages provide decision-making constructs (Conditional B

Read More

Functions

### Usage All C++ applications must have at least one function called `main()`. Additionally, you can have user-defined functions that encapsulate individual tasks, thus making the code cleaner and e

Read More

Hello World

This is the first article in the series OK. Let's do this. I keep trying to think of something big and interesting to write about, but that is just not working. All my time is spent trying to think o

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 series ["Vector"]({{config.site

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 significant issue with this simplistic server is that it can only handle connection

Read More

Smart-Pointer - Constructors

This article examines constructors that are often overlooked. It examines their use cases and explains why the added functionality is meaningful in relation to smart pointers. ## Default Constructor

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 `shared`

Read More

Smart-Pointer - Unique Pointer

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

Read More

Socket Programming in C

Building a simple client/server application is the standard first internet-based application developers attempt. These applications are built on top of the socket communication library, but socket pr

Read More

Socket Protocols

In the previous articles, I used a very simplistic protocol. In real-world situations, this protocol is not sufficient. A communications protocol is required to provide a more robust connection betwe

Read More

Socket Read/Write

## Checking read/write success The `read()` and `write()` commands can fail in several ways but can also succeed without reading/writing all the data. A common mistake is not checking the amount of

Read More

Variables

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

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

Many new developers of C++ attempt to build a `Vector` like container as a learning process. Getting a simple version of this working for POD types (like int) is not that complicated. The next step i

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

Read More

Vector - Simple Optimizations

Now that we have used `std::is_nothrow_move_constructible,` we can also examine a couple of other types available in the template utility library. # Optimized Destruction Since we have to manually

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 strictly is not required (unless you want to be c

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 various types of editors, etc. I don’t want to learn all abou

Read More