C++ low-level implementation of a client-server application I made in October 2020.
Back when I created this solution, I was really into C++. So I played around with POSIX threads and low-level binding to sockets. After fooling around, I ended up with an actual chat client and server which together work perfectly.
User can join a server, identify with a username, discover other active users, pick a user to chat with, get notified when another user joins in or leaves, and leave the server without the server crashing (laugh all you want, but back when I programmed this, the major problem was to not crash the server on any exit by user). The problem was also how to send messages, so there is an entire protocol set up for negotiating and exchanging messages.
In order to run the application, you need to be on a Linux system and have the ncurses library ready to be linked. Compile the application with:
g++ -g chat_klijent.cpp -lpthread -lncursesw -o chat_klijent
Given makefile statically links the ncurses library in the output file allowing you to run this piece of cool little software on any Linux system.
In order to compile chat_server, you need a -lpthread flag during compilation.
Everything in the UI is in Croatian. Back when I did this, I did it for my soul, not to show off to the world.
Left: server logging new user's join (Mislav). Right: client's UI.
Left: server logging another user's join (Ivan). Upper-right: original user's UI, which states another user has joined. Lower-right: new user's UI, empty
Ivan enters '?s' to look at available users. He is given a choice to pick the user he wants to chat with:
Example of chatting, with a server view as well. It's visible that UTF-8 characters čćšđž are correctly parsed by the server, but Windows CMD I was unfortunately using instead of a normal Linux Terminal failed to display these chars properly in the client app.
Example of Ivan leaving the chat gracefully.
Example of Ivan closing the client process with "kill".
Example of a long chat and an overfill which results in overwritting older messages from the top.