Fatih Çil

Self-Taught Developer

Software Engineer

Programmer

Game Developer

Fatih Çil

Self-Taught Developer

Software Engineer

Programmer

Game Developer

Blog Post

ft_irc: Building an IRC Server in C++98

January 10, 2023 École 42

Hi! ft_irc asks for a real IRC server in C++98 — one that genuine IRC clients can connect to. Another team project with cryonayes, and the first time my code spoke a real, standardized network protocol.

What we built

  • A TCP server multiplexing all clients on a single thread with poll() — no fork, no threads allowed,
  • Registration and authentication (PASS, NICK, USER),
  • Channels with joins, topics and modes, private messages with PRIVMSG/NOTICE,
  • Operators with KICK, INVITE, TOPIC, MODE (i/t/k/o/l),
  • And a bot as the bonus — a client of our own server, automated.

The lessons

The hardest part is not any single command — it is the stream nature of TCP. Commands arrive split across packets or glued together, so you need buffering per client and a parser that only acts on complete messages. Add partial sends, disconnects at the worst possible moment, and numeric replies that must match the RFC closely enough for real clients (we tested with irssi) to behave. NetPractice taught me how packets find a host; ft_irc taught me what happens after they arrive.

Source code: github.com/cryonayes/ft_irc

42 ft_irc badge

Related Posts