Skip to content

Repository files navigation

Wired – A Modern C++ Networking Library

Wired is a modern, open-source C++ networking library designed to simplify the development of cross-platform networked applications. It provides a clear and minimal API, supports asynchronous operations via Asio, and enables secure communication through OpenSSL.


Cloning the Repository

Clone the repository and initialize submodules:

git clone --recursive https://github.com/Robertkq/Wired.git

If you already cloned the repository without --recursive, run:

git submodule update --init --recursive

Installation

Wired uses CMake for building and installation.

  1. Create a build directory:

    mkdir build
    cd build
  2. Configure the project:

    cmake ..
  3. Build and install the library (requires admin privileges):

    sudo cmake --install .

Integration with Your Project

Once installed, you can use Wired in your own CMake project:

find_package(Wired REQUIRED)
find_package(OpenSSL REQUIRED)

add_executable(my_project main.cpp)
target_include_directories(my_project PRIVATE ${Wired_INCLUDE_DIRS})
target_link_libraries(my_project PRIVATE OpenSSL::SSL OpenSSL::Crypto)

Testing

Wired includes unit tests, static analysis, and code coverage tools.

Unit Tests

cd tests/unit
mkdir build
cd build
cmake ..
cmake --build . -j
./unit

Static Analysis

Make sure cppcheck is installed, then run:

cd tests/static_analyzer
mkdir build
cd build
cmake ..
cmake --build .

Code Coverage (Linux only)

  1. Run the unit tests as described above.
  2. Ensure lcov is installed.
  3. Generate coverage data:
lcov --capture --directory . --output-file coverage.info 
lcov --remove coverage.info '*13*' '*openssl*' '*/gtest/*' '*/asio/*' --output-file coverage_filtered.info
lcov --summary coverage_filtered.info
  1. Generate HTML report:
genhtml coverage_filtered.info --output-directory coverage_report

Example Applications

The examples/ directory contains demonstration applications built with Wired. These can be compiled and run on both Linux and Windows.

simple_application

Basic client-server communication.

cd examples/simple_application
mkdir build
cd build
cmake ..
cmake --build . -j
./server      # in one terminal
./client      # in another terminal

The client sends three messages ("ping") to the server, then disconnects.


chat

A basic multi-client chat server.

cd examples/chat
mkdir build
cd build
cmake ..
cmake --build . -j
./server
./client       # run in multiple terminals

Each client chooses a username. Messages are broadcast to all connected clients. Type exit to disconnect.


tic-tac-toe

A two-player networked tic-tac-toe game.

cd examples/tic-tac-toe
mkdir build
cd build
cmake ..
cmake --build . -j
./server
./client

Clients can type play to join the matchmaking queue. When two clients are queued, a game begins. Type exit to disconnect.


Notes

  • Commands are compatible with both Linux and Windows (PowerShell with compatible tooling).
  • On Windows, executables will have .exe extensions.
  • On Linux, make executables runnable if needed:
    chmod +x ./server
    chmod +x ./client
  • Logging is enabled by default. For unit tests, pass --help for options. For example applications, logging can be configured in each main.cpp.

About

Modern C++20 Networking library using asio

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages