A vintage Apple Macintosh SE personal computer with a CRT display and a beige, boxy design.

Having finished the core features of Willow CMS I was thinking about starting up a second side project. I was tinkering on my Mac SE and wondered what it would be like to write software on it. It was about 25 years ago that I last fired up CodeWarror on a Power Macintosh 7500 and first tinkered with C/C++ and about 20 since I last actually studied it at university. So after finding the amazing work Joshua Stein is doing with C on System 6 I decided to have a crack at it by aiming to write a peer-to-peer chat application. I’ll start by making it work on Ubuntu, then modern macOS and hopefully in the not too distant future System 6, 7, 8 and 9.

Why

This project will obviously give me exposure to socket programming in C both TCP and UDP communication over the network, of which I have vague memories and even some notebooks from university. It would also teach me about sending structured data over the network between clients with opportunity to focus on how to make that work across different architectures. Most importantly it could offer a way for me to transfer files between my Mac SE/PowerMac G4/macOS systems without having to setup Apple Talk etc - I could in theory just have a modern Mac and the Mac SE talking to each other much more easily. I’d doubt I’d be able to get any sort of modern SSL encryption working between all the clients, but we’ll see.

Anyway the code for this project is on GitHub and I’ve called it CSend for now. With the end goal of running it on a Mac SE and modern computers, maybe a more more Back to the Future themed name is in order. JiggaWhattsApp maybe?

Right now I’m up to v0.0.3 and have been tagging my efforts thus far from an initial simple client server setup to something still terminal based but with support for auto-discovery and messaging. I’m taking my time to review the code at each iteration and pour over both my old books and use Claude 3.7 to help me get back into this.

Here’s some info on what v0.0.3 currently offers (and doesn’t)

Core Functionality

  1. Peer-to-peer messaging without central server
  2. Auto-discovery of peers on local network
  3. Direct messaging between peers
  4. Broadcast messaging to all known peers

Network Features

  1. TCP for reliable message delivery (port 8080)
  2. UDP for peer discovery broadcasts (port 8081)
  3. Automatic IP detection for local network interfaces
  4. Peer timeout management (30 seconds)

User Interface

Command-line interface with simple commands:

  • /list - Display active peers
  • /send - Send direct message
  • /broadcast /broadcast
  • /quit - Exit application gracefully

Message Protocol

Text-based message protocol with format: TYPE|SENDER|CONTENT

Message types:

  1. DISCOVERY - Broadcast to find peers
  2. DISCOVERY_RESPONSEDISCOVERY_RESPONSE
  3. TEXT - Regular text messages
  4. QUIT - Notification when leaving network

Technical Implementation

  1. Multi-threaded architecture:
  2. Listener thread for incoming messages
  3. Discovery thread for peer detection
  4. User input thread for command processing
  5. Thread-safe peer management using mutexes
  6. Signal handling for graceful termination
  7. Timeout handling for network operations

Security & Limitations

  1. Basic username identification
  2. No encryption of messages
  3. No authentication mechanism
  4. Limited to local network by default
  5. Maximum of 10 concurrent peers

Tags

Programming C Code RetroComputing MacOS P2P Multithreading Networking