This is a *nix implementation of Computer Networking Chat App Project
xcode-select --install
libsocket/*.(cpp|h)
Shared socket logic between client and serverClient.h/cpp
Client socket logicServer.h/cpp
Server socket logicLogger.h/cpp
Logging messages to file
All other sources tie the project together but don't necessarily deal with sockets.
All TCP aspects have been completed. App now uses hooks architecture. Any time an error event occurs it runs the associated event handler stored in *Socket::*_handlers
. All possible errors are in libsocket/Errors.h
. Client and server processes now gracefully disconnect. The need for tmux
to kill the windows is no longer necessary because deadlocks have been fixed using ShutdownTasks
hooks, but it's still helpful for development.
This project requires the following dependencies for successful build:
- Homebrew (
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
) or equivalent package manager for *nix system - CMake (
brew install cmake
orsudo apt install cmake
or equivalent) - Xcode command line tools (Mac) or
build-essentials
package (Ubuntu) or equivalent ninja
build tool
Optionally, but highly recommended, tmux
.
From the same directory as this README, execute:
./build-and-start.sh # [build folder] [session name] <- optionals
This will build the project using CMake and fire up a tmux session with 1 server (port 33420) and 2 client panes automatically. It also enables mouse control for tmux to make it even easier 😁 also by running this script, if you detach CTRL+b d
from the session it will automatically kill the session for you.
If tmux
is not installed it will skip that part entirely.
From the same directory as this README perform the following steps:
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=ninja -G Ninja -S $PWD/..
cmake --build ./ --target all -j 4 # or however many number of CPU cores you want to use
Because this program disables echo and canonical input on stdin, using CTRL+C
does not work, so running these in their own tmux session is highly recommended so you can CTRL+b x y
to terminate the program in case a deadlock occurs. Or if running from the convenient build script just detaching will kill the processes.
In pch.h
there is using SocketSizeType = char;
. What's special about this is if you change it to another integer type it will automatically alter the TCP send and receive methods in the client and the server. Currently, the max message size is 255 because it's a char
, but setting it to short
will raise the max message size to 65535 and the partial message loop will read two bytes instead of just one 🤓.