7.3 KiB
7.3 KiB
Networking Handoff
Date: 2026-04-02
Commit: 5346d15 (Add KMP networking backends)
Scope completed
The lyngio networking work now provides a uniform Lyng-facing API with capability probes and platform-specific implementations.
Implemented modules:
lyng.io.httplyng.io.wslyng.io.net
Current support matrix
HTTP / HTTPS
- JVM: supported
- Android: supported
- JS: supported
- Linux Native: supported
- Windows Native (
mingwX64): supported - Apple Native: compile-verified on this Linux host
WS / WSS
- JVM: supported
- Android: supported
- JS: supported
- Linux Native: supported
- Windows Native (
mingwX64): supported - Apple Native: compile-verified on this Linux host
Raw networking (lyng.io.net)
- JVM: supported
- Android: supported
- JS/Node: supported
- JS/browser: unsupported by capability probe
- Linux Native: supported
- Apple Native: enabled via shared native backend; compile-verified, runtime not yet host-verified
- Other Native targets: intentionally still unsupported
Important design decisions
- Ktor is the backend for all currently implemented networking.
- API is uniform across targets; platform variance is exposed through capability checks such as:
Http.isSupported()Ws.isSupported()Net.isSupported()Net.isTcpAvailable()Net.isTcpServerAvailable()Net.isUdpAvailable()
- Native support was restricted to what matches Ktor client-engine support:
- Darwin for Apple Native
- Curl for Linux Native
- WinHttp for Windows Native
- Native raw sockets use a shared Ktor socket implementation for Linux and Darwin source sets.
- Capability probes are enabled on Linux Native and Apple Native; Apple Native is compile-verified but not yet runtime-tested on a macOS host.
Documentation and tests status
Docs updated:
docs/lyng.io.http.mddocs/lyng.io.ws.mddocs/lyng.io.net.md
Verified docs/tests:
- HTTP/HTTPS docs are covered with extracted markdown tests on JVM.
- WS/WSS docs are covered with extracted markdown tests on JVM.
- JS/Node has both engine-level and Lyng-module-level tests for raw networking.
Key implementation files
Shared:
lyngio/src/commonMain/kotlin/net/sergeych/lyngio/http/LyngHttp.ktlyngio/src/commonMain/kotlin/net/sergeych/lyng/io/http/LyngHttpModule.ktlyngio/src/commonMain/kotlin/net/sergeych/lyngio/ws/LyngWs.ktlyngio/src/commonMain/kotlin/net/sergeych/lyngio/net/LyngNet.ktlyngio/build.gradle.ktsgradle/libs.versions.toml
Platform HTTP:
lyngio/src/jvmMain/kotlin/net/sergeych/lyngio/http/PlatformJvm.ktlyngio/src/jsMain/kotlin/net/sergeych/lyngio/http/PlatformJs.ktlyngio/src/androidMain/kotlin/net/sergeych/lyngio/http/PlatformAndroid.ktlyngio/src/darwinMain/kotlin/net/sergeych/lyngio/http/PlatformDarwin.ktlyngio/src/linuxMain/kotlin/net/sergeych/lyngio/http/PlatformLinux.ktlyngio/src/mingwMain/kotlin/net/sergeych/lyngio/http/PlatformMingw.kt
Platform WS:
lyngio/src/jvmMain/kotlin/net/sergeych/lyngio/ws/PlatformJvm.ktlyngio/src/jsMain/kotlin/net/sergeych/lyngio/ws/PlatformJs.ktlyngio/src/androidMain/kotlin/net/sergeych/lyngio/ws/PlatformAndroid.ktlyngio/src/darwinMain/kotlin/net/sergeych/lyngio/ws/PlatformDarwin.ktlyngio/src/linuxMain/kotlin/net/sergeych/lyngio/ws/PlatformLinux.ktlyngio/src/mingwMain/kotlin/net/sergeych/lyngio/ws/PlatformMingw.kt
Platform raw net:
lyngio/src/jvmMain/kotlin/net/sergeych/lyngio/net/PlatformJvm.ktlyngio/src/jsMain/kotlin/net/sergeych/lyngio/net/PlatformJs.ktlyngio/src/androidMain/kotlin/net/sergeych/lyngio/net/PlatformAndroid.ktlyngio/src/nativeMain/kotlin/net/sergeych/lyngio/net/NativeKtorNetEngine.ktlyngio/src/linuxMain/kotlin/net/sergeych/lyngio/net/PlatformLinux.ktlyngio/src/darwinMain/kotlin/net/sergeych/lyngio/net/PlatformDarwin.ktlyngio/src/mingwMain/kotlin/net/sergeych/lyngio/net/PlatformMingw.kt
JS tests:
lyngio/src/jsTest/kotlin/net/sergeych/lyngio/PlatformCapabilityJsTest.ktlyngio/src/jsTest/kotlin/net/sergeych/lyngio/NetJsNodeTest.ktlyngio/src/jsTest/kotlin/net/sergeych/lyng/io/net/LyngNetModuleJsNodeTest.kt
JVM tests:
lyngio/src/jvmTest/kotlin/LyngioBookTest.ktlyngio/src/jvmTest/kotlin/net/sergeych/lyng/io/http/LyngHttpModuleTest.ktlyngio/src/jvmTest/kotlin/net/sergeych/lyng/io/ws/LyngWsModuleTest.ktlyngio/src/jvmTest/kotlin/net/sergeych/lyng/io/net/LyngNetModuleTest.kt
Linux Native tests:
lyngio/src/linuxTest/kotlin/net/sergeych/lyngio/net/NetLinuxNativeTest.kt
Verification already run
JVM / docs:
./gradlew :lyngio:jvmTest --tests LyngioBookTest./gradlew :lyngio:jvmTest --tests net.sergeych.lyng.io.http.LyngHttpModuleTest./gradlew :lyngio:jvmTest --tests net.sergeych.lyng.io.ws.LyngWsModuleTest./gradlew :lyngio:jvmTest --tests net.sergeych.lyng.io.net.LyngNetModuleTest
JS:
./gradlew :lyngio:compileKotlinJs./gradlew :lyngio:compileTestKotlinJs./gradlew :lyngio:jsNodeTest./gradlew kotlinUpgradeYarnLock
Android:
./gradlew :lyngio:compileDebugKotlinAndroid./gradlew :lyngio:compileReleaseKotlinAndroid
Native:
./gradlew :lyngio:compileKotlinLinuxX64./gradlew :lyngio:compileKotlinLinuxArm64./gradlew :lyngio:compileKotlinMingwX64./gradlew :lyngio:compileKotlinIosX64./gradlew :lyngio:compileKotlinIosArm64./gradlew :lyngio:compileKotlinIosSimulatorArm64./gradlew :lyngio:compileKotlinMacosArm64./gradlew :lyngio:compileTestKotlinLinuxX64./gradlew :lyngio:compileTestKotlinLinuxArm64./gradlew :lyngio:linkDebugTestLinuxX64./gradlew :lyngio:linuxX64Test./gradlew :lyngio:linuxX64Test --tests net.sergeych.lyngio.net.NetLinuxNativeTest./gradlew :lyngio:linuxX64Test --tests net.sergeych.lyngio.net.NetLinuxNativeTest.testLinuxNativeTcpAndUdpLoopback./lyngio/build/bin/linuxX64/debugTest/test.kexe --ktest_filter='net.sergeych.lyngio.net.NetLinuxNativeTest.*'
Known intentional gaps
- Native raw sockets are enabled on Linux Native and Apple Native.
- Apple Native raw networking is enabled based on shared-backend compile verification; runtime verification on macOS is still pending.
- No Android device/instrumented runtime tests were added; only compile verification was done.
Worktree state after commit
Current HEAD:
5346d15Add KMP networking backends
Unrelated remaining change:
examples/tetris_console.lyng
That file was not touched by the networking work and was intentionally left out of the commit.
Recommended next steps
- Add Native raw socket support only per target that compiles and passes a smoke test.
- Keep capability probes
falseon non-Linux Native targets until each raw-socket backend is proven. - If Apple Native work continues, compile Darwin targets on a macOS host before claiming support.
- Run a macOS-hosted runtime smoke test when available to verify the already-enabled Darwin backend.
- Optionally add Android runtime tests later; compile-only verification exists now.
Suggested first task for the next chat
Continue Native raw lyng.io.net incrementally from the verified Linux baseline:
- keep Linux Native enabled
- keep Apple Native enabled unless runtime verification disproves the shared-backend assumption
- keep other Native targets capability-gated off until compiled and smoke-tested
- use only
ktor-networksupport that actually compiles - do not change the Lyng-facing API