Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
192 changes: 181 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,52 @@ jobs:
build/tests_openbsd_x86_64
build/tests_header_only_openbsd_x86_64

omnios-x86_64-build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: vmactions/omnios-vm@v1
with:
usesh: true
prepare: |
pkg install cmake ninja gcc14
run: |
mkdir build && cd build
cmake -G "Ninja" ../ -DCMAKE_VERBOSE_MAKEFILE=ON -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON
cmake --build .
mv ./tests/tests ./tests_omnios_x86_64
mv ./tests/tests_header_only ./tests_header_only_omnios_x86_64
- uses: actions/upload-artifact@v4
with:
name: omnios-x86_64
path: |
build/tests_omnios_x86_64
build/tests_header_only_omnios_x86_64

omnios-x86_64-noifaddrs-build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: vmactions/omnios-vm@v1
with:
usesh: true
prepare: |
pkg install cmake ninja gcc14
run: |
mkdir build && cd build
cmake -G "Ninja" ../ -DCMAKE_VERBOSE_MAKEFILE=ON -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON -DCMAKE_C_FLAGS="-DTCS_HAS_GETIFADDRS=0"
cmake --build .
mv ./tests/tests ./tests_omnios_x86_64_noifaddrs
mv ./tests/tests_header_only ./tests_header_only_omnios_x86_64_noifaddrs
- uses: actions/upload-artifact@v4
with:
name: omnios-x86_64-noifaddrs
path: |
build/tests_omnios_x86_64_noifaddrs
build/tests_header_only_omnios_x86_64_noifaddrs

linux-s390x-build:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -404,6 +450,33 @@ jobs:
build/tests_android_x86_64
build/tests_header_only_android_x86_64

android-x86_64-api21-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nttld/setup-ndk@v1
with:
ndk-version: r27
id: ndk
- name: Build
run: |
mkdir build && cd build
cmake -G "Ninja" ../ \
-DCMAKE_TOOLCHAIN_FILE=${{ steps.ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=x86_64 \
-DANDROID_PLATFORM=android-21 \
-DTCS_ENABLE_TESTS=ON \
-DTCS_WARNINGS_AS_ERRORS=ON
cmake --build .
mv ./tests/tests ./tests_android_x86_64_api21
mv ./tests/tests_header_only ./tests_header_only_android_x86_64_api21
- uses: actions/upload-artifact@v4
with:
name: android-x86_64-api21
path: |
build/tests_android_x86_64_api21
build/tests_header_only_android_x86_64_api21

cygwin-x86_64-build:
runs-on: windows-latest
steps:
Expand Down Expand Up @@ -467,6 +540,7 @@ jobs:
- name: Run tests
shell: bash
run: |
set -o pipefail
echo '```' >> $GITHUB_STEP_SUMMARY
./build/tests_msvc_debug_x86.exe 2>&1 | tee -a $GITHUB_STEP_SUMMARY
./build/tests_msvc_release_x86.exe 2>&1 | tee -a $GITHUB_STEP_SUMMARY
Expand Down Expand Up @@ -510,6 +584,7 @@ jobs:
path: build/
- name: Run wine tests
run: |
set -o pipefail
echo '```' >> $GITHUB_STEP_SUMMARY
docker run --rm \
-v ${{ github.workspace }}:/workspace \
Expand Down Expand Up @@ -555,6 +630,7 @@ jobs:
path: build/
- name: Run wine tests
run: |
set -o pipefail
echo '```' >> $GITHUB_STEP_SUMMARY
docker run --rm \
-v ${{ github.workspace }}:/workspace \
Expand Down Expand Up @@ -586,10 +662,11 @@ jobs:
path: build/
- name: Run tests
run: |
set -o pipefail
echo '```' >> $GITHUB_STEP_SUMMARY
chmod +x ./build/tests_linux_musl_x86_64 ./build/tests_header_only_linux_musl_x86_64
./build/tests_linux_musl_x86_64 2>&1 | tee -a $GITHUB_STEP_SUMMARY
./build/tests_header_only_linux_musl_x86_64 2>&1 | tee -a $GITHUB_STEP_SUMMARY
sudo capsh --caps='cap_net_raw+eip' -- -c ./build/tests_linux_musl_x86_64 2>&1 | tee -a $GITHUB_STEP_SUMMARY
sudo capsh --caps='cap_net_raw+eip' -- -c ./build/tests_header_only_linux_musl_x86_64 2>&1 | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

linux-test-musl-x86:
Expand All @@ -603,10 +680,11 @@ jobs:
path: build/
- name: Run tests
run: |
set -o pipefail
echo '```' >> $GITHUB_STEP_SUMMARY
chmod +x ./build/tests_linux_musl_x86 ./build/tests_header_only_linux_musl_x86
./build/tests_linux_musl_x86 2>&1 | tee -a $GITHUB_STEP_SUMMARY
./build/tests_header_only_linux_musl_x86 2>&1 | tee -a $GITHUB_STEP_SUMMARY
sudo capsh --caps='cap_net_raw+eip' -- -c ./build/tests_linux_musl_x86 2>&1 | tee -a $GITHUB_STEP_SUMMARY
sudo capsh --caps='cap_net_raw+eip' -- -c ./build/tests_header_only_linux_musl_x86 2>&1 | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

linux-test-glibc-x86_64:
Expand All @@ -620,10 +698,11 @@ jobs:
path: build/
- name: Run tests
run: |
set -o pipefail
echo '```' >> $GITHUB_STEP_SUMMARY
chmod +x ./build/tests_linux_glibc_x86_64 ./build/tests_header_only_linux_glibc_x86_64
./build/tests_linux_glibc_x86_64 2>&1 | tee -a $GITHUB_STEP_SUMMARY
./build/tests_header_only_linux_glibc_x86_64 2>&1 | tee -a $GITHUB_STEP_SUMMARY
sudo capsh --caps='cap_net_raw+eip' -- -c ./build/tests_linux_glibc_x86_64 2>&1 | tee -a $GITHUB_STEP_SUMMARY
sudo capsh --caps='cap_net_raw+eip' -- -c ./build/tests_header_only_linux_glibc_x86_64 2>&1 | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

linux-test-glibc-x86:
Expand All @@ -637,8 +716,9 @@ jobs:
path: build/
- name: Run tests
run: |
set -o pipefail
echo '```' >> $GITHUB_STEP_SUMMARY
docker run --rm \
docker run --rm --cap-add=NET_RAW \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
i386/debian:bookworm sh -c '
Expand All @@ -659,6 +739,7 @@ jobs:
path: build/
- name: Run tests
run: |
set -o pipefail
echo '```' >> $GITHUB_STEP_SUMMARY
chmod +x ./build/tests_macos_arm64 ./build/tests_header_only_macos_arm64
./build/tests_macos_arm64 2>&1 | tee -a $GITHUB_STEP_SUMMARY
Expand All @@ -679,8 +760,12 @@ jobs:
usesh: true
run: |
chmod +x ./build/tests_freebsd_x86_64 ./build/tests_header_only_freebsd_x86_64
./build/tests_freebsd_x86_64 2>&1 | tee ./test_output.txt
./build/tests_header_only_freebsd_x86_64 2>&1 | tee -a ./test_output.txt
./build/tests_freebsd_x86_64 > /tmp/out1.txt 2>&1; s1=$?
cat /tmp/out1.txt
./build/tests_header_only_freebsd_x86_64 > /tmp/out2.txt 2>&1; s2=$?
cat /tmp/out2.txt
cat /tmp/out1.txt /tmp/out2.txt > ./test_output.txt
[ $s1 -eq 0 ] && [ $s2 -eq 0 ] || exit 1
- name: Write step summary
if: always()
run: |
Expand All @@ -702,8 +787,66 @@ jobs:
usesh: true
run: |
chmod +x ./build/tests_openbsd_x86_64 ./build/tests_header_only_openbsd_x86_64
./build/tests_openbsd_x86_64 2>&1 | tee ./test_output.txt
./build/tests_header_only_openbsd_x86_64 2>&1 | tee -a ./test_output.txt
./build/tests_openbsd_x86_64 > /tmp/out1.txt 2>&1; s1=$?
cat /tmp/out1.txt
./build/tests_header_only_openbsd_x86_64 > /tmp/out2.txt 2>&1; s2=$?
cat /tmp/out2.txt
cat /tmp/out1.txt /tmp/out2.txt > ./test_output.txt
[ $s1 -eq 0 ] && [ $s2 -eq 0 ] || exit 1
- name: Write step summary
if: always()
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
cat ./test_output.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

omnios-x86_64-test:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [omnios-x86_64-build]
steps:
- uses: actions/download-artifact@v4
with:
name: omnios-x86_64
path: build/
- uses: vmactions/omnios-vm@v1
with:
usesh: true
run: |
chmod +x ./build/tests_omnios_x86_64 ./build/tests_header_only_omnios_x86_64
./build/tests_omnios_x86_64 > /tmp/out1.txt 2>&1; s1=$?
cat /tmp/out1.txt
./build/tests_header_only_omnios_x86_64 > /tmp/out2.txt 2>&1; s2=$?
cat /tmp/out2.txt
cat /tmp/out1.txt /tmp/out2.txt > ./test_output.txt
[ $s1 -eq 0 ] && [ $s2 -eq 0 ] || exit 1
- name: Write step summary
if: always()
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
cat ./test_output.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

omnios-x86_64-noifaddrs-test:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [omnios-x86_64-noifaddrs-build]
steps:
- uses: actions/download-artifact@v4
with:
name: omnios-x86_64-noifaddrs
path: build/
- uses: vmactions/omnios-vm@v1
with:
usesh: true
run: |
chmod +x ./build/tests_omnios_x86_64_noifaddrs ./build/tests_header_only_omnios_x86_64_noifaddrs
./build/tests_omnios_x86_64_noifaddrs > /tmp/out1.txt 2>&1; s1=$?
cat /tmp/out1.txt
./build/tests_header_only_omnios_x86_64_noifaddrs > /tmp/out2.txt 2>&1; s2=$?
cat /tmp/out2.txt
cat /tmp/out1.txt /tmp/out2.txt > ./test_output.txt
[ $s1 -eq 0 ] && [ $s2 -eq 0 ] || exit 1
- name: Write step summary
if: always()
run: |
Expand All @@ -722,6 +865,7 @@ jobs:
path: build/
- name: Run tests
run: |
set -o pipefail
sudo apt-get update && sudo apt-get install -y qemu-user-static gcc-s390x-linux-gnu
echo '```' >> $GITHUB_STEP_SUMMARY
chmod +x ./build/tests_linux_s390x ./build/tests_header_only_linux_s390x
Expand Down Expand Up @@ -755,6 +899,32 @@ jobs:
adb shell /data/local/tmp/tests
adb shell /data/local/tmp/tests_header_only

android-x86_64-api21-test:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [android-x86_64-api21-build]
steps:
- uses: actions/download-artifact@v4
with:
name: android-x86_64-api21
path: build/
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
arch: x86_64
script: |
adb root
adb push build/tests_android_x86_64_api21 /data/local/tmp/tests
adb push build/tests_header_only_android_x86_64_api21 /data/local/tmp/tests_header_only
adb shell chmod +x /data/local/tmp/tests /data/local/tmp/tests_header_only
adb shell /data/local/tmp/tests
adb shell /data/local/tmp/tests_header_only

cygwin-x86_64-test:
runs-on: windows-latest
timeout-minutes: 30
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,19 @@ target_include_directories(
)
if(WIN32)
target_link_libraries(tinycsocket_header INTERFACE wsock32 ws2_32 iphlpapi)
elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
target_link_libraries(tinycsocket_header INTERFACE socket nsl)
endif()

# Tinycsocket static library
add_library(tinycsocket STATIC ${TINYCSOCKET_SRC})
add_library(tinycsockets ALIAS tinycsocket)
target_include_directories(tinycsocket PUBLIC include PRIVATE src)
target_link_libraries(tinycsocket PRIVATE tinycsocket_header)
# illumos/Solaris needs __EXTENSIONS__ for full POSIX visibility (like _GNU_SOURCE on glibc)
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
target_compile_definitions(tinycsocket PRIVATE __EXTENSIONS__ _XOPEN_SOURCE=500)
endif()
set_target_properties(tinycsocket PROPERTIES FOLDER tinycsocket)

if(TCS_WARNINGS_AS_ERRORS)
Expand All @@ -107,6 +113,9 @@ if(TCS_ENABLE_TESTS)
add_library(tinycsocket_wrapped STATIC ${TINYCSOCKET_SRC} "src/dbg_wrap.h")
target_include_directories(tinycsocket_wrapped PUBLIC include src)
target_link_libraries(tinycsocket_wrapped INTERFACE tinycsocket_header)
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
target_compile_definitions(tinycsocket_wrapped PRIVATE __EXTENSIONS__ _XOPEN_SOURCE=500)
endif()
target_compile_options(tinycsocket_wrapped PUBLIC "-DDO_WRAP")
endif()

Expand Down
57 changes: 30 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ See the example folder for information of how to use tinycsocket.
Currently supported platforms:
- Windows NT 5.0 SP1 (Windows 2000 SP1) or newer.
- POSIX.1-2001 compliant systems (Linux, FreeBSD, OpenBSD, MacOS, Solaris etc.)
- Android (API level 24+, partial support for earlier versions)
- Android (API level 24+ for full IPv6 interface support)

# Installation instructions

Expand Down Expand Up @@ -128,29 +128,32 @@ like.

These platforms are tested for every pull request. All configurations are tested as both static library and header-only.

| OS | Compiler | Arch | Notes |
|-----------------------------------|------------------------------------|----------|--------------|
| Windows Server 2025 | MSVC v19.44 | x86 | |
| Windows Server 2025 | MSVC v19.44 | x64 | |
| Windows Server 2025 | i686-w64-mingw32-gcc-posix v13 | x86 | WINVER 0x500 |
| Windows Server 2025 | i686-w64-mingw32-gcc-posix v13 | x86 | WINVER 0x502 |
| Windows Server 2025 | i686-w64-mingw32-gcc v15.2 | x86 | WINVER 0x603 |
| Windows Server 2025 | x86_64-w64-mingw32-gcc-posix v13 | x64 | WINVER 0x502 |
| Windows Server 2025 | x86_64-w64-mingw32-gcc v15.2 | x64 | WINVER 0x603 |
| Wine (Alpine 3.23) | MSVC v19.44 | x86 | |
| Wine (Alpine 3.23) | MSVC v19.44 | x64 | |
| Wine (Alpine 3.23) | i686-w64-mingw32-gcc-posix v13 | x86 | WINVER 0x500 |
| Wine (Alpine 3.23) | i686-w64-mingw32-gcc-posix v13 | x86 | WINVER 0x502 |
| Wine (Alpine 3.23) | i686-w64-mingw32-gcc v15.2 | x86 | WINVER 0x603 |
| Wine (Alpine 3.23) | x86_64-w64-mingw32-gcc-posix v13 | x64 | WINVER 0x502 |
| Wine (Alpine 3.23) | x86_64-w64-mingw32-gcc v15.2 | x64 | WINVER 0x603 |
| Linux Alpine 3.23 (musl) | gcc v15.2 | x86_64 | |
| Linux Alpine 3.23 (musl) | gcc v15.2 | x86 | |
| Linux Ubuntu 24.04 (glibc) | gcc v13.3 | x86_64 | |
| Linux Ubuntu 24.04 (glibc) | gcc v13.3 | x86 | |
| Linux Ubuntu 24.04 (glibc) | s390x-linux-gnu-gcc | s390x | Big-endian |
| MacOS (latest) | Apple Clang | arm64 | |
| FreeBSD 15.0 | Clang 19.1 | x86_64 | |
| OpenBSD (latest) | Clang | x86_64 | |
| Android API 24 (Bionic) | NDK Clang | x86_64 | Emulator |
| Cygwin (Windows Server 2025) | gcc | x86_64 | |
| OS | Compiler | Arch | Notes |
|-----------------------------------|------------------------------------|----------|--------------------------|
| Windows Server 2025 | MSVC v19.44 | x86 | |
| Windows Server 2025 | MSVC v19.44 | x64 | |
| Windows Server 2025 | i686-w64-mingw32-gcc-posix v13 | x86 | WINVER 0x500 |
| Windows Server 2025 | i686-w64-mingw32-gcc-posix v13 | x86 | WINVER 0x502 |
| Windows Server 2025 | i686-w64-mingw32-gcc v15.2 | x86 | WINVER 0x603 |
| Windows Server 2025 | x86_64-w64-mingw32-gcc-posix v13 | x64 | WINVER 0x502 |
| Windows Server 2025 | x86_64-w64-mingw32-gcc v15.2 | x64 | WINVER 0x603 |
| Wine (Alpine 3.23) | MSVC v19.44 | x86 | |
| Wine (Alpine 3.23) | MSVC v19.44 | x64 | |
| Wine (Alpine 3.23) | i686-w64-mingw32-gcc-posix v13 | x86 | WINVER 0x500 |
| Wine (Alpine 3.23) | i686-w64-mingw32-gcc-posix v13 | x86 | WINVER 0x502 |
| Wine (Alpine 3.23) | i686-w64-mingw32-gcc v15.2 | x86 | WINVER 0x603 |
| Wine (Alpine 3.23) | x86_64-w64-mingw32-gcc-posix v13 | x64 | WINVER 0x502 |
| Wine (Alpine 3.23) | x86_64-w64-mingw32-gcc v15.2 | x64 | WINVER 0x603 |
| Linux Alpine 3.23 (musl) | gcc v15.2 | x86_64 | |
| Linux Alpine 3.23 (musl) | gcc v15.2 | x86 | |
| Linux Ubuntu 24.04 (glibc) | gcc v13.3 | x86_64 | |
| Linux Ubuntu 24.04 (glibc) | gcc v13.3 | x86 | |
| Linux Ubuntu 24.04 (glibc) | s390x-linux-gnu-gcc | s390x | Big-endian |
| MacOS (latest) | Apple Clang | arm64 | |
| FreeBSD 15.0 | Clang 19.1 | x86_64 | |
| OpenBSD (latest) | Clang | x86_64 | |
| Android API 24 (Bionic) | NDK Clang | x86_64 | Emulator |
| Android API 21 (Bionic) | NDK Clang | x86_64 | Emulator, ioctl fallback |
| OmniOS (illumos) | gcc | x86_64 | |
| OmniOS (illumos) | gcc | x86_64 | ioctl fallback |
| Cygwin (Windows Server 2025) | gcc | x86_64 | |
Loading
Loading