Building a simple server with C++
In this article, I’m going to explain how to create a very simple server with C++. The server will receive a single message, send a response and then quit. For network programming in C++, we need to use some low level C functions that translate directly to syscalls.
Let’s explore the syscalls we’ll need.
socket
We’ll use the socket function to create a socket. A socket can be seeen as a file descriptor that can be used for communication.
This is the signature of the function:
1
int socket(int domain, int type, int protocol);