An IRC server that actually works.
A fully functional Internet Relay Chat server written in C++98,
implementing the IRC protocol (RFC 2812) with authentication, channels,
operator privileges, and bonus features including a bot and file transfer.
๐ Note: This is a collaborative project. The original repository is Abdellatif404/Internet-Relay-Chat. This fork showcases my contributions while maintaining full attribution to the team.
- About
- The IRC Protocol
- Features
- Architecture
- Commands
- Getting Started
- Usage Examples
- Bonus Features
- Technical Details
- Team & Contributions
- Author
ft_irc is a 42 School project that requires building an IRC server from scratch in C++98. The server must handle multiple simultaneous clients using non-blocking I/O and epoll() for event-driven networking.
Internet Relay Chat (IRC) is a real-time text messaging protocol from 1988 โ the grandfather of modern chat systems like Slack and Discord.
IRC ARCHITECTURE
Client A โโโโโโ
โ
Client B โโโโโโผโโโโโ IRC SERVER โโโโโโโ Client D
โ (ircserv)
Client C โโโโโโ port 6667
Our server implements RFC 2812 โ the IRC client protocol specification:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ IRC MESSAGE FORMAT โ
โ โ
โ :<prefix> <command> <params> :<trailing> โ
โ โ
โ Example: โ
โ :nick!user@host PRIVMSG #channel :Hello! โ
โ โ
โ Max message length: 512 bytes (including โ
โ the CR-LF terminator) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- โ Authentication โ password-protected server access
- โ Nicknames & Users โ NICK/USER registration per RFC
- โ Channels โ create, join, leave, and manage channels
- โ Private Messages โ direct user-to-user messaging
- โ Channel Modes โ invite-only, topic lock, key, user limit
- โ Operator Privileges โ KICK, INVITE, TOPIC, MODE
- โ
Non-blocking I/O โ
epoll()event-driven architecture - โ Multiple Clients โ concurrent connections without threads
- โ Graceful Handling โ partial messages, disconnections, errors
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SERVER ARCHITECTURE โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ epoll() โ โโโ โ Event Loop โ โ
โ โ wait โ โ โข Accept new clients โ โ
โ โโโโโโโโโโโโ โ โข Read from sockets โ โ
โ โ โ โข Parse commands โ โ
โ โ โ โข Execute & respond โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Socket โ โ โ
โ โ fd pool โ โผ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Command Dispatcher โ โ
โ โ NICK, JOIN, PRIVMSG โ โ
โ โ KICK, MODE, TOPIC... โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Command | Syntax | Description |
|---|---|---|
PASS |
PASS <password> |
Authenticate with server password |
NICK |
NICK <nickname> |
Set or change nickname |
USER |
USER <user> 0 * :<realname> |
Register username |
QUIT |
QUIT [:<message>] |
Disconnect from server |
| Command | Syntax | Description |
|---|---|---|
JOIN |
JOIN <#channel> [key] |
Join a channel |
PART |
PART <#channel> [:<message>] |
Leave a channel |
TOPIC |
TOPIC <#channel> [:<topic>] |
View/set channel topic |
NAMES |
NAMES <#channel> |
List users in channel |
| Command | Syntax | Description |
|---|---|---|
PRIVMSG |
PRIVMSG <target> :<message> |
Send message to user/channel |
NOTICE |
NOTICE <target> :<message> |
Send notice (no auto-reply) |
| Command | Syntax | Description |
|---|---|---|
KICK |
KICK <#channel> <user> [:<reason>] |
Remove user from channel |
INVITE |
INVITE <user> <#channel> |
Invite user to channel |
MODE |
MODE <#channel> <+/-flags> [params] |
Set channel modes |
| Mode | Flag | Description |
|---|---|---|
| Invite-only | +i |
Only invited users can join |
| Topic lock | +t |
Only operators can change topic |
| Channel key | +k <key> |
Password-protected channel |
| User limit | +l <count> |
Maximum number of users |
| Operator | +o <nick> |
Grant/revoke operator status |
make # Build the server
make clean # Remove object files
make fclean # Full clean
make re # Rebuild./ircserv <port> <password>
# Example
./ircserv 6667 mypasswordirssi -c localhost -p 6667 -w mypasswordnc -C 127.0.0.1 6667
PASS mypassword
NICK mynick
USER myuser 0 * :Real Name
JOIN #general
PRIVMSG #general :Hello everyone!- Add new network โ Server:
localhost/6667 - Set server password:
mypassword - Connect and join channels
An automated bot that responds to commands and provides utility functions within channels.
Direct Client-to-Client file transfer โ allows users to send files directly to each other through the IRC server.
| Aspect | Implementation |
|---|---|
| I/O Model | Non-blocking with epoll() |
| Standard | C++98 strict compliance |
| Concurrency | Single-threaded, event-driven |
| Protocol | RFC 2812 (IRC Client Protocol) |
| Max Message | 512 bytes including CRLF |
| Compatible Clients | irssi, HexChat, WeeChat, netcat |
This was a collaborative 42 project. Full attribution to all team members:
| Member | GitHub | Contributions |
|---|---|---|
| Abdellatif | @Abdellatif404 | Server core, channel management |
| Adil Bourji | @adi7-x | Command parsing, operator privileges, testing |
๐ Original repository: Abdellatif404/Internet-Relay-Chat
Adil Bourji โ @adi7-x
42 School ยท Common Core ยท Networking ยท C++