The examples are complete programs built from the same library sources as the test suite. Use them to see how the libraries fit together, then follow the links to the source when you need the implementation details.
See the examples in action
These recordings show the larger examples running before you explore their source or the focused command-line programs below.
Applications and runtime behavior
AsyncWebServer
Static files, streamed uploads, and a shared WebSocket canvas running in two browser windows.
Serialization and state
Reflected application state moving between binary and JSON representations.
Plugin loading and hot reload
SCExample loading native plugins and replacing them while the host keeps running.
SC::Build workflows
Native standalone build
The native backend compiling and linking the repository directly, without generating an IDE project first.
External project bootstrap
A small external project fetching the launcher with curl and building from its own SC-build.cpp.
Quick start
Build and run an example from the repository root:
./SC.sh build compile AwaitEcho Debug
./SC.sh build run AwaitEcho DebugUse SC.bat instead of ./SC.sh on Windows. Project generation, IDE setup, and platform prerequisites are covered in
Building (Contributor).
HTTP and networking
- ApiServer is a small routed HTTP API with health, query, and streaming echo endpoints.
- SaneHttpGet is the shortest blocking
HttpClientexample. - HttpClientPollSession shows a poll-driven client session with caller-owned storage.
- HttpClientAsyncGet connects
HttpClienttoAsyncStreamsand anAsyncEventLoop. - AsyncWebServer is the advanced HTTP laboratory for static files, uploads, WebSockets, configurable connection storage, and Linux backend selection.
To serve a directory with AsyncWebServer, pass an absolute path after --:
./SC.sh build compile AsyncWebServer Debug
./SC.sh build run AsyncWebServer Debug -- --directory /absolute/path/to/siteAwait cookbook
Warning:
Awaitis currently experimental. These examples are complete programs for exploring the coroutine API, not a stable compatibility promise.
Task ownership and coordination
AwaitBackgroundJobsmanages detached work in fixed caller-owned registry slots.AwaitDeadlineapplies a deadline and cooperative cancellation to a child task.AwaitFirstResponseraces two jobs and cancels the slower one.
Networking
AwaitEchois the baseline TCP client/server conversation.AwaitDatagramPingdemonstrates a bounded UDP request and reply.AwaitLineProtocolbuilds a small CRLF-framed protocol.
File I/O
AwaitConfigReloadcomposes a child task that reads a configuration file.AwaitFilePatchperforms explicit offset writes and reads.AwaitManifestPreviewreads into a bounded preview buffer until full or EOF.AwaitTaskGroupFilesreads multiple files with a task group.AwaitFileCouriercombines file operations with file-to-socket transfer.
System integration
AwaitBackgroundDigestmoves bounded CPU work to a thread pool.AwaitCallbackBridgeruns callback-styleAsyncand coroutine-styleAwaiton the same event loop.AwaitProcessExitCodeswaits for multiple child processes.AwaitThreadWakeUpdelivers another thread's signal to an Await coroutine.
Composed workflow
AwaitServiceProbecombines networking, task groups, background work, timeouts, and explicit shutdown.
All Await sources are under the Examples directory and use their directory name as the build target.
Fibers
- FibersDemo demonstrates CPU fibers,
FibersAsyncsleeps, and worker-pool work in three focused sections. - FibersBenchmark is a maintainer benchmark for scheduler, contention, and sustained micro-task workloads.
- FibersSkynetBenchmark is an
opt-in comparison with Taskflow's upstream Skynet backend. Install it with
./SC.sh package install taskflow-benchmarksbefore configuring the benchmark target. - FibersStackGrowthPrototype is a maintainer prototype for stack-growth behavior.
Benchmark results depend on the machine and build configuration; they are development measurements rather than portable performance claims.
Native integration and hot reload
SCExample is the native Sokol and Dear ImGui
host used to exercise Async, plugins, file watching, state handoff, and hot reload. Its plugins are:
CollaborativeCanvasExample, which hosts a browser canvas through HTTP and WebSockets;SerializationExample, which demonstrates reflected state and binary/JSON serialization;WebServerExample, which configures a static file server from the native UI.
SCExample is an integration testbed rather than the shortest introduction to any individual library. Start with a focused console example when learning one API.
More source-backed examples
The library pages contain compiled snippets for individual APIs. The tests provide broader executable reference code, including error paths and platform-specific behavior. See Tests and the library catalog when an example above is broader than the question you are trying to answer.