A C networking SDK for LAN peer-to-peer communication between modern POSIX systems and Classic Macintosh computers.
- 29-function C89 API with a single public header (
peertalk.h) - 3 platform backends: POSIX (BSD sockets), MacTCP (68k/PPC), Open Transport (PPC)
- Zero allocation after init — all buffers pre-allocated in a single block
- Automatic peer discovery via UDP broadcast with instant leave notification
- Reliable (TCP) and fast (UDP) message transports
- ~4,700 lines of SDK code across all platforms
| Platform | Backend | Build Target | Tested Hardware |
|---|---|---|---|
| Linux / macOS | POSIX (BSD sockets) | build/ |
Any modern system |
| Mac SE (68000) | MacTCP | build-68k/ |
Mac SE, 4 MB RAM |
| Performa 6200 (PPC 603) | MacTCP | build-ppc-mactcp/ |
Performa 6200, 40 MB RAM |
| Performa 6400 (PPC 603e) | Open Transport | build-ppc-ot/ |
Performa 6400, 48 MB RAM |
| Performa 630 (68LC040) | Open Transport | build-68k-ot/ |
Performa 630 (pending) |
#include "peertalk.h"
PT_Context *ctx;
PT_Init(&ctx, "MyApp");
PT_OnPeerDiscovered(ctx, on_discovered, NULL);
PT_OnConnected(ctx, on_connected, NULL);
PT_OnMessage(ctx, MSG_CHAT, on_chat, NULL);
PT_RegisterMessage(ctx, MSG_CHAT, PT_RELIABLE);
PT_StartDiscovery(ctx);
while (running) {
PT_Poll(ctx);
}
PT_Shutdown(ctx);See API Contract for the full 29-function reference.
- Retro68 fork for Classic Mac cross-compilation (
$RETRO68_TOOLCHAIN) - clog — fetched automatically via FetchContent, or pass
-DCLOG_DIR=pathfor a local checkout
# POSIX
mkdir -p build && cd build && cmake .. && make
# 68k MacTCP (Retro68 cross-compiler)
mkdir -p build-68k && cd build-68k
cmake .. -DCMAKE_TOOLCHAIN_FILE=$RETRO68_TOOLCHAIN/m68k-apple-macos/cmake/retro68.toolchain.cmake \
-DPT_PLATFORM=MACTCP && make
# PPC Open Transport (Retro68 cross-compiler)
mkdir -p build-ppc-ot && cd build-ppc-ot
cmake .. -DCMAKE_TOOLCHAIN_FILE=$RETRO68_TOOLCHAIN/powerpc-apple-macos/cmake/retroppc.toolchain.cmake \
-DPT_PLATFORM=OT && make# Option 1: FetchContent (automatic download of peertalk + clog)
include(FetchContent)
FetchContent_Declare(clog
GIT_REPOSITORY https://github.com/matthewdeaves/clog.git
GIT_TAG main
GIT_SHALLOW TRUE
)
set(CLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(clog)
FetchContent_Declare(peertalk
GIT_REPOSITORY https://github.com/matthewdeaves/peertalk.git
GIT_TAG main
GIT_SHALLOW TRUE
)
set(PEERTALK_BUILD_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(peertalk)
target_link_libraries(myapp PRIVATE peertalk clog)
# Option 2: Local checkout
set(PEERTALK_BUILD_TESTS OFF)
add_subdirectory(${PEERTALK_DIR} ${CMAKE_BINARY_DIR}/peertalk)
target_link_libraries(myapp PRIVATE peertalk)include/peertalk.h # Single public header (C89, 29 functions)
src/core/ # Platform-independent core
src/platform/posix/ # BSD sockets + select()
src/platform/mactcp/ # MacTCP async parameter blocks
src/platform/opentransport/ # OT endpoints + notifiers
tests/ # 7 test apps
| App | Pattern | What it tests |
|---|---|---|
| test_lifecycle | Connection | Discovery, connect, disconnect, reconnect, StopDiscovery, SetName, PeerLost |
| test_reliable | Chess (TCP) | Ordered reliable message exchange, chunking/reassembly |
| test_fast | Bomberman (UDP) | High-frequency positional updates at 60 Hz |
| test_chat | Chat (TCP) | Variable-length bidirectional messages |
| test_multi | Multi-peer | N-way discovery, connect all, broadcast to all, verify receipt |
| test_init_only | Init/shutdown | Memory allocation, error path validation (10 checks) |
| test_clog_minimal | Logging | clog library verification |
Deploy and run test binaries on real Classic Mac hardware using the classic-mac-hardware-mcp MCP server. See its README for setup.
All test apps verified on real Classic Mac hardware:
- Mac SE (68000, System 6.0.8, MacTCP): test_lifecycle, test_reliable, test_multi PASS
- Performa 6200 (PPC 603, System 7.5.3, MacTCP): test_lifecycle, test_reliable, test_multi, test_init_only PASS
- Performa 6400 (PPC 603e, System 7.6.1, Open Transport): test_lifecycle, test_reliable, test_multi, test_init_only PASS
4-peer multi-peer test verified: all 4 machines (POSIX + Mac SE + 6200 + 6400) discovering, connecting, and exchanging broadcasts simultaneously.
- Every feature serves Bomberman, Chess, or Chat
- Pre-allocate everything at init, zero malloc after
- Poll-based I/O on all platforms (no threads)
- C89 for maximum portability
- Measure on real hardware, document honestly
- Architecture Diagrams — C4 Mermaid diagrams (Context, Container, Component, Deployment)
- API Contract
- Specification
- Research Decisions
Retro68 (cross-compilation) + clog (auto-fetched) -> peertalk -> csend, BomberTalk