Getting Started - Part 0
Howdy! I decided to take on the difficult journey of writing a tutorial for of all things, a multi-threaded chat server. Not only will we build this from scratch, we’ll also use C as the back end with Java as the front end. Realistically, you could probably use anything for the front end, but just for experimentation, we’ll do it this way.
Before we get started, I’ll first explain a couple of thing that we’re not doing, either out of simplicity or just because it’s too complex for what I want to demonstrate in this tutorial:
So, what will we do?
Now that that’s out of the way, let’s discuss what I expect of you (i.e., what you should know coming into this):
So, before we start programming, we have to set up a few preliminary things, namely our development environment(s) for the respective languages.
First off, you need MacOS or a Linux environment. I’m going to use two: both a MacBook Pro 2017 and a copy of Xubuntu 20.04 for experimentation. As long as it’s not a Windows environment (since we’re working with pthreads), it should work fine. You can use a virtual machine with VirtualBox, VMWare, Hyper-V, or something else (possibly even WSL…) if you don’t want to install Linux on your own hardware.
Additionally, you need an environment and compiler for C. I’ll be using VSCode since it has become sort of the de-facto standard for programming on Linux. For a compiler, if you’re on Linux, then gcc is the way to go. On Mac, I recommend either that or clang.
Regarding Java, I will be using OpenJDK 15 and the IntelliJ IDE. Any IDE should work for this, though (Eclipse, NetBeans, BlueJ…).
Setting everything up is relatively straightforward, I’ll leave that to you since it’s irrelevant to actually designing the server. There are plenty of resources available to get you started with it. I’ll take care of everything else.
One other thing that I’ll emphasize with this project is that I’m going to actively encourage good programming practices and paradigms. While I’m obviously not a programming prodigy in C nor Java, there are certain things we can do to make our code easy to maintain and debug. So, we’ll be using GitHub for our version control software, Valgrindfor memory leaks/dynamic memory, and gdb for debugging in C.
With that out of the way, let's write us a chat server!