PeerTalk is a C networking SDK for LAN peer-to-peer communication between modern POSIX systems and Classic Macintosh computers. It provides a 29-function C89 API with a single public header, automatic peer discovery via UDP broadcast, and both reliable (TCP) and fast (UDP) message transports. About 4,600 lines of SDK code across all platforms.

PT_Context *ctx;
PT_Init(&ctx, "MyApp");
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), 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

  • 29-function C89 API with a single public header
  • Automatic peer discovery via UDP broadcast with instant leave notification
  • 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. 4-peer multi-peer test verified across all four machines simultaneously.

Platform Backend Hardware Verified Tests
Linux / macOS POSIX Any modern system All 7 test apps
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, building against the clog dependency and running the POSIX test suite.

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