Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
160c5c5
Experiment to add initial networking support to KDUtils
seanharmer Apr 4, 2025
256a696
Add basic DNS resolver based on c-ares library
seanharmer Apr 4, 2025
7d9e9b6
Implement a new Uri class
seanharmer Apr 4, 2025
f6b384a
Convert utils tests to use same structure as other modules
seanharmer Apr 5, 2025
334b599
Introduce IpAddress class and use it in DnsResolver and TcpSocket
seanharmer Apr 5, 2025
df74401
Update TcpServer to use IpAddress and add simple states
seanharmer Apr 5, 2025
1e1b8a4
Improve and cleanup TcpSocket
seanharmer Apr 6, 2025
54b05cf
Examples use IpAddress
seanharmer Apr 6, 2025
5e61482
Const fix ups
seanharmer Apr 6, 2025
0fb2422
First successful test of HttpClient with a local http server
seanharmer Apr 7, 2025
ce1b90f
Add test for HttpSession
seanharmer Apr 7, 2025
faf7999
Add test for HttpRequest
seanharmer Apr 7, 2025
7cfd19b
Fix failing tests
seanharmer Apr 7, 2025
0f97865
Sketch out some possible ideas for future work
seanharmer Apr 7, 2025
a448d11
Add singleShot property to Timer
seanharmer Apr 8, 2025
28d78a6
Use single shot timer for timeouts
seanharmer Apr 8, 2025
251f81f
Add SslSocket and use within HttpClient
seanharmer Apr 8, 2025
34566b0
Add a simple OpenAI client example
seanharmer Apr 9, 2025
6b88b1b
Use ssize_t in TcpSocket
seanharmer Apr 15, 2025
7d33a89
Add initial support for Server Sent Events SSE
seanharmer Apr 15, 2025
fb8e5d2
Don't warn when user initiated disconnection
seanharmer Apr 15, 2025
94091ac
Make the openai sse example more useful
seanharmer Apr 15, 2025
9ecd0ff
Initial websocket support
seanharmer Apr 16, 2025
13fc32f
Rework the websocket connection logic
seanharmer Apr 16, 2025
a81aa29
We don't need the timer now we properly handle the upgrade
seanharmer Apr 16, 2025
82ae942
Improve Timer class to offer convenience helpers
seanharmer Apr 17, 2025
121130c
Use new timer helpers to reduce boilerplate
seanharmer Apr 17, 2025
b83d3f1
Mark timer helpers as nodiscard
seanharmer Apr 17, 2025
06224c9
Cleanup: Remove unnecesary member declarations
seanharmer May 6, 2025
39c7122
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 6, 2025
f445979
Usee https to clone nlohman/json
seanharmer May 6, 2025
d0f6ce3
Be more explicit about bytearray ctor selection
seanharmer May 6, 2025
f08f7f3
Add comment to kdutils test cmake function
seanharmer May 6, 2025
13372d0
Add missing licensing
seanharmer May 6, 2025
ac5c41b
Ignore the *-plan.md files from linting
seanharmer May 6, 2025
0df52ea
Add .markdownlintignore to REUSE.toml
seanharmer May 6, 2025
a2c4081
Use manual exclusion of md files in pre-commit config
seanharmer May 6, 2025
d183164
Be explicit about ignoring connection handle
seanharmer May 6, 2025
6332d25
Another bytearray ctor fix for macOS clang
seanharmer May 6, 2025
5122115
Explicitly link to KDUtils and KDBindings
seanharmer May 6, 2025
d83fbe0
KDBindings uses lowercase include path
seanharmer May 6, 2025
4f93f16
Require OpenSSL 3.0 as min
seanharmer May 6, 2025
741e43d
Use vcpkg to install OpenSSL dependency
seanharmer May 6, 2025
1f7a6ad
Attempt to use vcpkg in github actions
seanharmer May 6, 2025
3a5ca24
Use correct vcpkg action package name
seanharmer May 7, 2025
84e6821
Calculate triplet from matrix OS and use github.token
seanharmer May 7, 2025
e8f8326
Try simple list of OS and triplets
seanharmer May 7, 2025
0fddd05
Include triplet alongside OS
seanharmer May 7, 2025
7acb1bc
Install linux-libc-dev in github action runner
seanharmer May 7, 2025
8d93b96
Focus on Ubuntu 24.04 for now
seanharmer May 7, 2025
fb9f646
Add windows back into the mix
seanharmer May 7, 2025
223763f
Use manifest mode for vcpkg
seanharmer May 7, 2025
063a4e4
Enable ubuntu 22.04 and 24.04 on arm
seanharmer May 7, 2025
41b9c01
Fix triplet on arm
seanharmer May 7, 2025
59e1924
Re-enable macos
seanharmer May 7, 2025
76e87c3
Use arm64 for macos-15
seanharmer May 7, 2025
32bb491
Arm64 on macos-14 too
seanharmer May 7, 2025
70dcb62
Set up vcpkg and OpenSSL 3 for linters and build-external
seanharmer May 8, 2025
48d11c6
Fix variable deref
seanharmer May 8, 2025
c2ae061
Use vcpkg with clang-tidy configuration
seanharmer May 8, 2025
254dea1
Fix some clang-tidy suggestions in Uri
seanharmer May 8, 2025
c01c639
Fix a bunch of clang-tidy warnings
seanharmer May 8, 2025
787bfa5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 8, 2025
30e973f
Rename example class
seanharmer May 14, 2025
15fda1d
Fix KDNetwork related issues from cppcheck
seanharmer May 14, 2025
14a8a91
Make cppcheck happy
seanharmer May 14, 2025
7f71de4
Bump c-ares version to include clang on windows fixes
seanharmer Jun 12, 2025
296eeec
Remove duplicated configurations in build matrix
seanharmer Jun 12, 2025
71d5c79
Move gcov setup to before declaring a new project
seanharmer Jun 12, 2025
e0e08f2
Stop clang-tidy error about empty catch blocks
seanharmer Jun 12, 2025
9665f80
Silence some clang-tidy warnings in tcp socket
seanharmer Jun 12, 2025
28fb638
More clang-tidy fixes for TcpSocket
seanharmer Jun 13, 2025
d2901fd
Avoid narrowing conversion
seanharmer Jun 13, 2025
90ad30b
Fix narrowing conversion warning in TcpSocket
seanharmer Jun 17, 2025
409cc9c
Don't suggest using boost ranges
seanharmer Jun 17, 2025
040eb0b
More const correctness
seanharmer Jun 17, 2025
bdfc131
Prefer std::array to c-style arrays
seanharmer Jun 17, 2025
c579399
clang-tidy fixes for Uri and tests
seanharmer Jun 18, 2025
bf235e7
clang-tidy fixes to http cookie and tests
seanharmer Jun 18, 2025
a41a25a
clang-tidy fixes for dns resolver tests
seanharmer Jun 18, 2025
c277b05
Disable timer tests on macOS in CMake configuration
seanharmer Jun 18, 2025
335c3b5
Clang-tidy fixes related to connect return type
seanharmer Jun 18, 2025
bcdef77
Clang-tidy fixes for Socket
seanharmer Jun 18, 2025
f99fc89
Avoid a copy
seanharmer Jun 18, 2025
c8c2513
Clang-tidy fixes to timer test
seanharmer Jun 18, 2025
315cba6
Clang-tidy fixes for http request tests
seanharmer Jun 18, 2025
a228d3b
Misc clang-tidy test fixes
seanharmer Jun 18, 2025
dea4f1e
Prefer std::array to c-style buffers
seanharmer Jun 18, 2025
338ef23
Websocket client clang-tidy fixes
seanharmer Jun 18, 2025
6e36910
Don't let exceptions escape destructor
seanharmer Jun 18, 2025
17af490
More clang-tidy fixes
seanharmer Jun 18, 2025
e0f1791
Pass callback by const-ref
seanharmer Jun 18, 2025
c26a020
Fix some clang-tidy warnings in HttpClient
seanharmer Jun 18, 2025
46e7be9
Clang-tidy fixes for http client
seanharmer Jun 18, 2025
ef6b8b3
Fix narrowing conversion
seanharmer Jun 18, 2025
861da4c
Clang-tidy fixes for SslSocket
seanharmer Jun 18, 2025
4001fe0
Clang-tidy fixes for http parser
seanharmer Jun 19, 2025
468d41e
Clang-tidy fixes for http response
seanharmer Jun 19, 2025
e3cdcac
Clang-tidy fixes for sse client
seanharmer Jun 19, 2025
2c2ca24
Clang-tidy fixes for http session
seanharmer Jun 19, 2025
b53f50a
Access array via data()
seanharmer Jun 19, 2025
85ce7ee
Disable MQTT in clang-tidy profile
seanharmer Jul 10, 2025
61f9e38
Resolve/silence clang-tidy errors on Linux builds
seanharmer Jul 10, 2025
449e92c
Fix clang-tidy warnings outside of kdnetwork
seanharmer Jul 10, 2025
b11ebdf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2025
e3c616f
Disable some network tests on macOS
seanharmer Jul 21, 2025
5b75a43
Extend README.md to mention KDNetwork being experimental
seanharmer Jul 21, 2025
152fba3
Fix line length in readme
seanharmer Jul 21, 2025
93e6c76
Fix rebase issues and warnings on latest msvc
seanharmer Aug 5, 2025
6340dfd
Silence performance-avoid-endl check
seanharmer Aug 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 52 additions & 50 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
---
Checks: '*,
clang-analyzer-*,
clang-diagnostic-*,
-abseil-*,
-altera-*,
-android-*,
-bugprone-suspicious-include,
-boost-use-ranges,
-clang-analyzer-alpha.core.CastToStruct,
-clang-analyzer-alpha.deadcode.UnreachableCode,
-clang-analyzer-alpha*,
-clang-analyzer-core.CallAndMessage,
-clang-analyzer-core.NonNullParamChecker,
-clang-analyzer-cplusplus.NewDeleteLeaks,
-clang-analyzer-optin.core.EnumCastOutOfRange,
-clang-diagnostic-gnu-zero-variadic-macro-arguments,
-cppcoreguidelines-*,
-fuchsia-*,
-google-*,
-hicpp-*,
-llvm-*,
-llvm-include-order,
-llvm-namespace-comment,
-llvmlibc-*,
-misc-include-cleaner,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-modernize-loop-convert,
-modernize-pass-by-value,
-modernize-raw-string-literal,
-modernize-return-braced-init-list,
-modernize-use-bool-literals,
-modernize-use-default-member-init,
-modernize-use-default,
-modernize-use-emplace,
-modernize-use-equals-default,
-modernize-use-override,
-modernize-use-trailing-return-type,
-modernize-use-using,
-readability-braces-around-statements,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-implicit-bool-cast,
-readability-implicit-bool-conversion,
-readability-magic-numbers,
-readability-named-parameter,
-readability-qualified-auto,
-readability-uppercase-literal-suffix,
-readabilty-namespace-comments'
clang-analyzer-*,
clang-diagnostic-*,
-abseil-*,
-altera-*,
-android-*,
-boost-use-ranges,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-suspicious-include,
-clang-analyzer-alpha.core.CastToStruct,
-clang-analyzer-alpha.deadcode.UnreachableCode,
-clang-analyzer-alpha*,
-clang-analyzer-core.CallAndMessage,
-clang-analyzer-core.NonNullParamChecker,
-clang-analyzer-cplusplus.NewDeleteLeaks,
-clang-analyzer-optin.core.EnumCastOutOfRange,
-clang-diagnostic-gnu-zero-variadic-macro-arguments,
-cppcoreguidelines-*,
-fuchsia-*,
-google-*,
-hicpp-*,
-llvm-*,
-llvm-include-order,
-llvm-namespace-comment,
-llvmlibc-*,
-misc-include-cleaner,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-modernize-loop-convert,
-modernize-pass-by-value,
-modernize-raw-string-literal,
-modernize-return-braced-init-list,
-modernize-use-bool-literals,
-modernize-use-default-member-init,
-modernize-use-default,
-modernize-use-emplace,
-modernize-use-equals-default,
-modernize-use-override,
-modernize-use-trailing-return-type,
-modernize-use-using,
-performance-avoid-endl,
-readability-braces-around-statements,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-implicit-bool-cast,
-readability-implicit-bool-conversion,
-readability-magic-numbers,
-readability-named-parameter,
-readability-qualified-auto,
-readability-uppercase-literal-suffix,
-readabilty-namespace-comments'
WarningsAsErrors: ''
HeaderFilterRegex: ''
CheckOptions:
- key: cert-oop11-cpp.UseCERTSemantics
value: '1'
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/build-external.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ on:

jobs:
build:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: true
matrix:
os:
- macos-latest
platform:
- os: macos-latest
triplet: arm64-osx-release
shared:
- ON
- OFF
Expand All @@ -39,11 +40,20 @@ jobs:
brew tap KDAB/tap
brew install fmt spdlog KDBindings mosquitto

- name: Set up vcpkg
id: vcpkg
uses: johnwason/vcpkg-action@v6
with:
token: ${{ github.token }}
triplet: ${{ matrix.platform.triplet }}
manifest-dir: ${{ github.workspace }}

- name: Configure project
run: >
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Debug -G Ninja
-DKDUTILS_BUILD_TESTS=ON
-DBUILD_SHARED_LIBS=${{ matrix.shared }}
${{ steps.vcpkg.outputs.vcpkg-cmake-config }}

- name: Check if external dependencies were used
run: |
Expand Down
40 changes: 30 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@ on:

jobs:
build:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-24.04
- ubuntu-22.04
- ubuntu-24.04-arm
- windows-2022
- macos-13
- macos-14
- macos-15
platform:
- os: ubuntu-24.04
triplet: x64-linux-release
- os: ubuntu-22.04
triplet: x64-linux-release
- os: ubuntu-24.04-arm
triplet: arm64-linux-release
- os: windows-2022
triplet: x64-windows-release
- os: macos-13
triplet: x64-osx-release
- os: macos-14
triplet: arm64-osx-release
- os: macos-15
triplet: arm64-osx-release
build_type:
- Debug
- Release
Expand Down Expand Up @@ -54,7 +61,8 @@ jobs:
sudo apt install -y libxkbcommon-dev libxcb-xkb-dev \
libxkbcommon-x11-dev wayland-scanner++ wayland-protocols \
libwayland-dev xvfb ninja-build \
libmosquitto-dev gcovr
libmosquitto-dev gcovr \
linux-libc-dev

- name: Download mosquitto (MacOS)
if: runner.os == 'macOS'
Expand All @@ -68,13 +76,25 @@ jobs:
https://mosquitto.org/files/binary/win64/mosquitto-$env:MOSQUITTO_VERSION-install-windows-x64.exe
& .\mosquitto-$env:MOSQUITTO_VERSION-install-windows-x64.exe /S

- name: Set up vcpkg
id: vcpkg
uses: johnwason/vcpkg-action@v6
with:
token: ${{ github.token }}
triplet: ${{ matrix.platform.triplet }}
manifest-dir: ${{ github.workspace }}

- name: Configure project
run: >
cmake -S . -B ./build -G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DKDUTILS_CODE_COVERAGE=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
-DKDUTILS_BUILD_TESTS=${{ matrix.build_type == 'Debug' }}
-DBUILD_SHARED_LIBS=${{ matrix.link_type == 'shared' }}
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
-DVCPKG_TARGET_TRIPLET=${{ matrix.platform.triplet }}
-DVCPKG_MANIFEST_MODE=OFF
${{ steps.vcpkg.outputs.vcpkg-cmake-config }}

- name: Build Project
run: cmake --build ./build
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ jobs:
include:
- name: Ubuntu
os: ubuntu-24.04
triplet: x64-linux-release
# Specify executable name on Linux to have control over the version.
# Sadly, on Linux these per-version executables aren't there.
tidy-executable: clang-tidy-18
- name: Windows
os: windows-2022
triplet: x64-windows-release
tidy-executable: clang-tidy
fail-fast: false

Expand All @@ -44,11 +46,20 @@ jobs:
libxkbcommon-x11-dev wayland-scanner++ wayland-protocols \
libwayland-dev xvfb ninja-build cppcheck libmosquitto-dev

- name: Set up vcpkg
id: vcpkg
uses: johnwason/vcpkg-action@v6
with:
token: ${{ github.token }}
triplet: ${{ matrix.triplet }}
manifest-dir: ${{ github.workspace }}

- name: Configure project
run: >
cmake -S . -B build -G Ninja -DKDUTILS_BUILD_TESTS=True
-DCMAKE_CXX_CLANG_TIDY="${{matrix.tidy-executable}}"
-DCMAKE_BUILD_TYPE=Release -DKDUTILS_BUILD_TESTS=ON
${{ steps.vcpkg.outputs.vcpkg-cmake-config }}

- name: Build Project
shell: pwsh
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
rev: v0.18.1
hooks:
- id: markdownlint-cli2
exclude: ^(3rdParty/|common/ui/resources/licenses/)
exclude: ^(3rdParty/|common/ui/resources/licenses/|kdnetwork-plan.md|sse-plan.md|websockets-plan.md)
files: \.(md|mdown|markdown)$
- repo: https://github.com/fsfe/reuse-tool
rev: v5.0.2
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

cmake_policy(SET CMP0090 NEW) # Stop export(PACKAGE) from modifying the system-wide cmake package system
cmake_policy(SET CMP0117 NEW) # Do not add /GR to CMAKE_CXX_FLAGS
cmake_policy(SET CMP0135 NEW) # Use current timestamp when extracting tarball for FetchContent

option(KDUTILS_BUILD_EXAMPLES "Build examples" ON)
option(KDUTILS_BUILD_NETWORK_SUPPORT "Build KDNetwork" ON)

include(FeatureSummary)
include(CMakeDependentOption)
Expand Down Expand Up @@ -72,6 +74,10 @@ add_subdirectory(src/KDUtils)
add_subdirectory(src/KDFoundation)
add_subdirectory(src/KDGui)

if(KDUTILS_BUILD_NETWORK_SUPPORT)
add_subdirectory(src/KDNetwork)
endif()

if(KDUTILS_BUILD_MQTT_SUPPORT)
add_subdirectory(src/KDMqtt)
endif()
Expand Down
11 changes: 7 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 2,
"version": 3,
"configurePresets": [
{
"name": "configure-base",
Expand All @@ -25,7 +25,8 @@
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
}
},
"toolchainFile": "${env.VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "debug",
Expand Down Expand Up @@ -85,8 +86,10 @@
"binaryDir": "${sourceDir}/build/Release-clangtidy",
"cacheVariables": {
"CMAKE_CXX_CLANG_TIDY": "clang-tidy",
"KDUTILS_BUILD_TESTS": "ON"
}
"KDUTILS_BUILD_TESTS": "ON",
"KDUTILS_BUILD_MQTT_SUPPORT": "OFF"
},
"toolchainFile": "${env.VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "profile",
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ You may also want to have a look at the
[CI configuration](https://github.com/KDAB/KDUtils/blob/main/.github/workflows/build.yml)
of this project to see which dependencies we use to build KDMqtt.

## KDNetwork

KDNetwork provides an experimental event-driven networking library on top of raw BSD sockets,
KDFoundation and KDBindings.

This library is still considered unstable and in development. As such we do not make any promises
for API or ABI stability at this time. Please do feel free to take it for a test drive on Windows
or Linux.

KDNetwork offers support for TCP and SSL/TLS socket communications; non-blocking DNS resolution
queries; higher-level protocols such as HTTPS, Server Sent Events and WebSockets.

## KDUtils/KDUtils

This namespace is the namesake of the entire library, and contains the STL
Expand Down
4 changes: 2 additions & 2 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ SPDX-License-Identifier = "MIT"

#misc documentation
[[annotations]]
path = ["ChangeLog", "**README.md"]
path = ["ChangeLog", "**README.md", "kdnetwork-plan.md", "sse-plan.md", "websockets-plan.md"]
precedence = "aggregate"
SPDX-FileCopyrightText = "Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>"
SPDX-License-Identifier = "MIT"

#misc config files
[[annotations]]
path = [".pre-commit-config.yaml", ".codespellrc", ".krazy", ".cmake-format.py", "**.clang-format", ".clang-tidy", "**.gitignore", ".gitreview", ".markdownlint.jsonc", "appveyor.yml", "REUSE.toml"]
path = [".pre-commit-config.yaml", ".codespellrc", ".krazy", ".cmake-format.py", "**.clang-format", ".clang-tidy", "**.gitignore", ".gitreview", ".markdownlint.jsonc", ".markdownlintignore", "appveyor.yml", "REUSE.toml", "vcpkg.json"]
precedence = "aggregate"
SPDX-FileCopyrightText = "Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>"
SPDX-License-Identifier = "BSD-3-Clause"
Expand Down
Loading
Loading