An open API service indexing awesome lists of open source software.

https://github.com/mortinger91/cpp-tcp-udp-sockets

A somewhat educational project featuring sockets. TCP and UDP server and client
https://github.com/mortinger91/cpp-tcp-udp-sockets

Last synced: 10 months ago
JSON representation

A somewhat educational project featuring sockets. TCP and UDP server and client

Awesome Lists containing this project

README

          

[![main](https://github.com/mortinger91/cpp-tcp-udp-sockets/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/mortinger91/cpp-tcp-udp-sockets/actions/workflows/main.yml)

# cpp-tcp-udp-sockets

### Easy CMake C++ project that uses sockets. Supports Linux and macOS.

- TCP server:
Listen on a port for incoming TCP connections.
Prints everything it receives through the connection in the stdout.
Sends the message it has received through the connection.
- TCP client:
Connect to an endpoint and port.
Prints everything it receives through the connection in the stdout.
- UDP server:
Listen on a port for incoming UDP datagrams.
Multiple clients can send datagrams at its IP address and port.
Prints everything it receives in the stdout.
Sends back to the specific client the message it has received.
- UDP client:
Connect to an endpoint and port.
Prints everything it receives through the connection in the stdout.

Requirements:
--------------
- CMake
- Clang
- LLDB
- clang-format (optional)
- VSCode 'CodeLLDB' extension (optional)

Set up project:
--------------
./ProjectFolder/scripts/build_cmake_debug.sh

or execute VSCode task `build_cmake_debug`.

Build and Debug:
----------------
./ProjectFolder/scripts/build_debug.sh

Followed by:

lldb ./build/Debug/bin/cpp-cmake-template

or launch VSCode `DEBUG` configuration.

Run tests:
----------
./ProjectFolder/scripts/run_tests.sh

or execute VSCode task `run_tests`.

### Run tests in a Docker container:

docker compose down --volumes --rmi all
docker compose up

Build release:
--------------
./ProjectFolder/scripts/create_release.sh

or execute VSCode task ```create_release```.

Notes:
=======

- To add new files:
- create a new folder in ```ProjectFolder/src```
- add ```*.cpp``` and ```*.h``` files into it.
- Remember to re-run ```build_cmake_debug```
- To add new tests:
- add new ```test_*.cpp``` files in ```ProjectFolder/test```.
- Remember to re-run ```build_cmake_debug```