You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
β Output Buffering - Queued sends with POLLOUT management
β Signal Handling - Graceful shutdown on SIGINT/SIGTERM
β Colored Logging - ANSI-colored server logs for debugging
π§ Requirements
Compiler: g++ or clang++ with C++98 support
OS: Linux (tested on Ubuntu/Debian)
Build tool: make
Client: Any IRC client (WeeChat, irssi, HexChat, nc)
π¦ Installation
# Clone the repository
git clone <your-repo-url> ft_irc
cd ft_irc
# Build the project
make
# The binary 'ircserv' will be created in the root directory
Compilation Flags
-Wall -Wextra -Werror -std=c++98 -g3
π Usage
Starting the Server
./ircserv <port><password>
Example:
./ircserv 6667 mySecurePass123
Output:
[INFO] Starting IRC server on port 6667
[INFO] Password required for connection: mySecurePass123
[INFO] Listening on 0.0.0.0:6667
Press Ctrl+C to stop the server
Connecting with a Client
Using netcat (quick test)
nc 127.0.0.1 6667
PASS mySecurePass123
NICK alice
USER alice 0 * :Alice Wonderland
JOIN #general
PRIVMSG #general :Hello everyone!
QUIT :Goodbye
Using WeeChat
weechat
/server add local 127.0.0.1/6667 -password=mySecurePass123
/connect local
/nick alice
/join #general
Using irssi
irssi
/connect 127.0.0.1 6667 mySecurePass123 alice
/join #general
ποΈ Architecture
Single Poll() Loop
ββββββββββββββββββββββββββββββββββββββββββββ
β Main Loop (Server::run) β
β β
β while (!signal) { β
β poll(_pfds, _nfds, 100ms); β β ONE poll() call
β β
β if (POLLIN on listening socket) β
β β accept_new_clients() β (1 accept/cycle)
β β
β if (POLLIN on client socket) β
β β process_client_messages() β (1 read/client)
β β
β if (POLLOUT on client socket) β
β β flush output buffers β (1 send/client)
β } β
ββββββββββββββββββββββββββββββββββββββββββββ
# Terminal 1
nc 127.0.0.1 6667
PASS mySecurePass123
NICK alice
USER alice 0 * :Alice
JOIN #test# Terminal 2
nc 127.0.0.1 6667
PASS mySecurePass123
NICK bob
USER bob 0 * :Bob
JOIN #test
PRIVMSG #test :Hello alice!
3. Channel Modes
MODE #test +i # Invite-only
MODE #test +t # Topic protection
MODE #test +k secret # Set password
MODE #test +l 10 # Max 10 users
MODE #test +o alice # Give alice operator
4. Partial Data (Subject Requirement)
# Send command in fragments (simulating slow connection)
(printf "PA"; sleep 0.1;printf"SS pass"; sleep 0.1;printf"123\r\n") | nc 127.0.0.1 6667
# Expected: Server correctly assembles and processes "PASS pass123"
π Technical Details
Compliance with Subject Requirements
β Non-blocking I/O
All sockets use O_NONBLOCK via fcntl(fd, F_SETFL, O_NONBLOCK)
No other fcntl() usage (F_GETFL forbidden by subject)
β Single poll()
Exactly 1poll() call in entire codebase (src/Server.cpp:110)
No select(), epoll(), or kqueue()
Verify with: grep -r "poll(" src/
β poll() before I/O
Every accept() preceded by POLLIN check
Every read() preceded by POLLIN check
Every send() preceded by POLLOUT check
No errno checking for EAGAIN to trigger actions (forbidden by subject)
β Partial Data Handling
Input buffer accumulates data until complete line
Supports both \r\n (CRLF) and \n (LF) line endings
Tested with fragmented input (see test_partial_data.sh)
Error Handling
Socket errors: Logged and client disconnected
Unknown commands: 421 ERR_UNKNOWNCOMMAND
Missing parameters: 461 ERR_NEEDMOREPARAMS
Privilege errors: 481/482 ERR_NOPRIVILEGES
Channel errors: 403/471/473/475 (No such channel, full, invite-only, bad key)
Internet Relay Chat (IRC) is a text-based communication protocol on the Internet. It offers real-time messaging that can be either public or private. Users can exchange direct messages and join group channels.