PeerTalk is a C networking SDK for LAN peer-to-peer communication between Classic Macintosh computers, modern POSIX systems, and old Mac OS X machines on both PowerPC and Intel. It provides a 31-function C89 API with a single public header, automatic peer discovery via UDP broadcast, an optional self-forming full mesh, and both reliable (TCP) and fast (UDP) message transports. About 4,700 lines of SDK code across all platforms.

PT_Context *ctx;
PT_Init(&ctx, "MyApp");
PT_EnableAutoMesh(ctx, 1);        /* SDK forms and heals the full mesh */
PT_OnPeerDiscovered(ctx, on_discovered, 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);

The SDK handles three platform backends: POSIX (BSD sockets, covering Linux and Mac OS X on both PowerPC and Intel), MacTCP (68k/PPC), and Open Transport (68k/PPC). All buffers are pre-allocated in a single block at init, so there's zero allocation after startup.

# Platform Backends

The same 29-function API compiles against three completely different networking stacks. Application code never touches sockets, streams, or endpoints directly.

Application Code CSend, BomberTalk, or your own PeerTalk API peertalk.h · 29 functions · poll-based I/O POSIX select() · non-blocking BSD Sockets MacTCP ASR callbacks · PBs MacTCP Driver (.IPP) Open Transport OT notifiers · endpoints Open Transport API

# Discovery and Connection

Peers find each other via UDP broadcast, then form a TCP mesh for reliable communication. The whole lifecycle is callback-driven through PT_Poll().

Peer A Peer B UDP broadcast (port 7353) UDP broadcast (port 7353) every 2s OnPeerDiscovered(B) OnPeerDiscovered(A) PT_Connect(B) PT_Connect(A) TCP (port 7354) IP tiebreaker resolves duplicate connections OnConnected(B) OnConnected(A) TCP reliable + UDP fast messages

# Features

  • 31-function C89 API with a single public header
  • Automatic peer discovery via UDP broadcast with instant leave notification
  • Optional self-forming full mesh: the SDK owns who connects to whom, race-free (each pair dialled from one side) and self-healing
  • Universal Mac OS X build: one binary for both PowerPC and Intel (10.4 to 10.7), with a separate PowerPC build reaching 10.3.9
  • Reliable (TCP) and fast (UDP) message transports
  • TCP keepalives prevent inactivity timeout during UDP-heavy gameplay
  • Peer ranking API for deterministic ID assignment across all machines
  • Bulk disconnect for lobby/game/lobby lifecycle transitions
  • Debug broadcast channel for remote log monitoring
  • Three platform backends: POSIX, MacTCP, Open Transport
  • Zero allocation after init (all buffers pre-allocated)
  • Poll-based I/O on all platforms (no threads)

# Tech Stack

C89 BSD Sockets MacTCP Open Transport CMake Retro68

# Hardware Testing

All test apps pass on real Classic Mac hardware, and the POSIX backend now runs on old Mac OS X too, on both PowerPC and Intel. A 4-peer multi-peer test is verified across all four Classic machines simultaneously.

Platform Backend Hardware Verified Tests
Linux / macOS POSIX Any modern system All 7 test apps
Mac OS X (PowerPC) POSIX Power Mac G3, G4, G5 (10.3.9 to 10.5) lifecycle
Mac OS X (Intel) POSIX Intel Mac mini (10.7) lifecycle
Mac SE (68000) MacTCP Mac SE, 4 MB RAM lifecycle, reliable, multi
Performa 6200 (PPC 603) MacTCP Performa 6200, 40 MB RAM lifecycle, reliable, multi, init_only
Performa 6400 (PPC 603e) Open Transport Performa 6400, 48 MB RAM lifecycle, reliable, multi, init_only

The test suite covers lifecycle (discovery, connect, disconnect, reconnect), reliable messaging (TCP), fast messaging (UDP at 60 Hz), bidirectional chat, multi-peer broadcast, and init/shutdown validation.

# Development approach

The repository uses SpecKit for specification-driven development. The specs/ directory contains structured feature specifications with user scenarios, acceptance criteria, data models, and implementation plans. GitHub Actions runs CI on every push: it cross-compiles all three Classic Mac backends, runs a cppcheck static-analysis sweep, and builds the POSIX backend against the clog dependency. A 120-check unit-test suite exercises the core logic on the host through a mock backend, with no sockets or real hardware, so a single pass covers all three backends at once.

# Dependency Chain

PeerTalk sits in the middle of the Classic Mac networking stack. clog provides the logging. CSend and BomberTalk both build on top of it. The Classic Mac Hardware MCP handles deployment and remote execution on the real hardware.

Retro68 clog PeerTalk CSend BomberTalk