Skip to content

Selboukaoui/IRC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project has been created as part of the 42 curriculum by [ababdoul], [Selboukaoui], [mhoussas].

ft_irc

Description

ft_irc is a fully functional IRC (Internet Relay Chat) server implemented in C++98. The goal of the project is to build a server that handles multiple simultaneous client connections, follows the IRC protocol (RFC 1459), and supports real IRC clients such as LimeChat, irssi, or netcat.

The server supports:

  • Simultaneous client connections using poll()
  • User authentication via password, nickname, and username registration
  • Channel management (join, leave, messaging)
  • Operator commands (kick, invite, topic, mode)
  • Private messaging between users

Instructions

Requirements

  • C++ compiler supporting C++98 (g++ or clang++)
  • A Unix-based system (Linux or macOS)
  • make

Compilation

make

Execution

./ircserv <port> <password>

Example:

./ircserv 6667 mypassword

Testing with netcat

nc localhost 6667
PASS mypassword
NICK yournick
USER yournick localhost localhost Real_Name
JOIN #general
PRIVMSG #general :Hello everyone!

Testing with a real IRC client (LimeChat / irssi)

  • Host: localhost
  • Port: 6667
  • Server password: the password you used to start the server

Features

Commands implemented

Command Description
PASS Authenticate with server password
NICK Set or change nickname
USER Register username and real name
JOIN Join one or multiple channels (JOIN #a,#b)
PART Leave one or multiple channels
PRIVMSG Send a message to a channel or a user
QUIT Disconnect from the server
KICK Remove a user from a channel (operator only)
INVITE Invite a user to a channel
TOPIC View or set the channel topic
MODE Set channel or user modes

Channel modes supported

Mode Description
+i Invite-only channel
+t Topic settable by operators only
+k Channel password (key)
+o Give/take operator privilege
+l Set user limit

Project Structure

ft_irc/
├── header.hpp               — shared includes and declarations
├── main.cpp                 — entry point
├── Makefile
├── README.md
│
├── authentication/
│   ├── authentication.cpp   — registration flow orchestration
│   ├── PASS.cpp             — password authentication
│   ├── NICK.cpp             — nickname registration and validation
│   └── USER.cpp             — username and realname registration
│
├── client/
│   ├── client.cpp           — Client class (poll list + client info)
│   └── client.hpp           — t_info struct and Client class
│
├── server/
│   ├── server.cpp           — main server loop
│   ├── server.hpp           — Server class and declarations
│   ├── channel.hpp          — Channel struct/class
│   ├── utils.cpp            — socket helpers (bind, listen, poll, recv, send)
│   └── welcom.cpp           — welcome replies (001 002 003 004)
│
└── cmds/
    ├── cmds.hpp             — all command function declarations
    ├── parse.cpp            — IRC message parser
    ├── JOIN.cpp             — join channels
    ├── PART.cpp             — leave channels
    ├── PRIVMSG.cpp          — send messages to channels or users
    ├── QUIT.cpp             — disconnect from server
    ├── KICK.cpp             — remove a user from a channel
    ├── INVITE.cpp           — invite a user to a channel
    ├── TOPIC.cpp            — view or set channel topic
    └── MODE.cpp             — channel and user modes

Resources

IRC Protocol

Networking in C/C++

AI Usage

Claude (claude.ai) was used throughout this project for:

  • Architecture design — understanding how to structure the server loop, Client class, and command dispatcher
  • Debugging — identifying bugs in poll loop, buffer management, and command parsing
  • Command implementation guidance — step-by-step explanation of what each IRC command must do, which numeric replies to send, and edge cases to handle (e.g. multi-channel JOIN, buffer splitting on \r\n)
  • IRC protocol understanding — explaining numeric reply codes, the registration flow (PASS -> NICK -> USER), and message format (:prefix COMMAND params :trailing\r\n)
  • Code review — reviewing JOIN, PRIVMSG, PART, and QUIT implementations for bugs before testing

AI was used as a learning and debugging tool. All code was written and understood by the team members.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors