Open source · Featured · 2023
Sockets, from scratch.
Act I
Most chat apps quietly route everything through a server. For a networks course, the whole point was to not do that: real peer-to-peer messaging on raw sockets, with a registry only for discovery and a heartbeat tracking who’s actually online.
Act II
A Python CLI chat built on raw sockets. A threaded central registry handles auth and discovery, but every peer also runs its own TCP server for direct one-to-one chat, presence rides a UDP heartbeat, and MongoDB-backed rooms fan messages out over UDP.
Intermission, the demo
a packet and its ack, no server in between, the whole point, in one hop
The cast
Read the card, then flip it to watch the mechanism run.
0x01
A self-rescheduling one-second UDP heartbeat plus a per-user timeout reaper on the registry keeps an accurate online list without polling.
how it works
0x02
The registry stays centralized for auth and discovery while messaging is decentralized, so each client is at once a TCP client and its own threaded TCP server.
how it works
0x03
Member IP and port lists come from the registry, and room messages go out as direct datagrams to each member under registry-side locks.
how it works