Overview
We built a fully working IRC server from scratch in C++98 as part of the 42 curriculum. It works with real clients, spin it up, connect with irssi, join channels, set modes, kick people. Three of us worked on it over a few weeks.
Built with Ayoub Diri and Mohammed Akarkaou.
What We Built
- User registration (
PASS,NICK,USER) - Channels:
JOIN,PART,INVITE,KICK,TOPIC PRIVMSGfor both channels and direct messages- Channel modes:
+i(invite-only),+t(topic lock),+k(password),+o(op),+l(user limit) PING/PONGkeepalive andQUIT- Non-blocking sockets: with
poll(), one loop handles everything - CalcBot: a built-in bot that evaluates math expressions in channels
- DCC relay: transparently forwards CTCP/DCC messages for peer-to-peer file transfers
Key Concepts
- Running a single
poll()loop across all connected clients instead of spawning threads - Parsing IRC messages correctly: the protocol has a lot of edge cases
- Keeping per-client and per-channel state in sync without it turning into a mess
- Dealing with partial TCP reads: one command doesn't always arrive in one packet
- C++98 specifically: no lambdas, no smart pointers, no
auto, good discipline (or it is?? lol)
What is IRC?
IRC is a chat protocol from the late 80s. Before Slack, Discord, or Teams existed, developers and open source communities used it to talk in real time. Some still do.
The concept is simple: connect to a server, pick a nickname, join channels like #general, send messages. The server handles routing, if you message a channel, everyone in it gets it instantly.
Implementing that server is where it gets interesting. This project is a common systems programming exercise because it forces you to deal with networking at a low level, no libraries, just sockets, a protocol spec, and a lot of edge cases. It's not about building a chat app, it's about understanding how real-time communication actually works underneath.