A lightweight IRC (Internet Relay Chat) server implemented in C++98, following the IRC protocol requirements defined in the 42 ft_irc project.
The project focuses on building a high-performance event-driven server using non-blocking sockets and a single I/O multiplexing loop (poll() or equivalent), capable of handling multiple concurrent clients without threads or processes.
- TCP/IP client-server communication
- Password authentication
- Nickname and username registration
- Channel creation and management
- Private messaging
- Channel broadcasting
- Channel operators
- IRC channel modes
- Invite-only (
+i) - Topic restriction (
+t) - Channel key (
+k) - Operator privileges (
+o) - User limit (
+l)
- Invite-only (
- Graceful client disconnection and cleanup
The server follows an event-driven architecture based on a single non-blocking event loop.
+----------------+
| TCP Listener |
+--------+-------+
|
accept()
|
+----------v-----------+
| poll() Loop |
+----------+-----------+
|
+--------------+--------------+
| |
Read Events Write Events
| |
Command Parser Message Queue
| |
+--------------+--------------+
|
IRC Command Router
|
+---------------+----------------+
| |
Client Manager Channel Manager
- TCP/IP sockets
- Non-blocking I/O
- Socket lifecycle
- Connection management
- Event multiplexing with
poll()
- Event-driven architecture
- File descriptor management
- Resource cleanup
- Memory ownership
- Error handling
- Graceful shutdown
- IRC command parsing
- Incremental packet buffering
- Handling fragmented TCP packets
- Message routing
- Protocol validation
- Separation of concerns
- Object-oriented design (C++98)
- Command dispatcher pattern
- State management
- Encapsulation
- Modular architecture
- Single-threaded event loop
- Concurrent client handling without threads
- Fair scheduling through readiness notifications
- Handling partial TCP packets correctly
- Supporting multiple commands within a single receive buffer
- Preventing blocking operations
- Maintaining channel consistency
- Managing client lifecycle safely
- Ensuring robustness under malformed or unexpected input
The server was validated using:
- Multiple simultaneous clients
- Partial packet delivery
- Message flood tests
- Invalid command handling
- Authentication edge cases
- Channel permission validation
- Connection/disconnection stress tests
- Long message handling
- Duplicate nickname scenarios
makeRun:
./ircserv <port> <password>Example:
./ircserv 6667 secret- Modern C++
- POSIX Sockets
- poll()
- Make
- Linux / macOS
This project provides practical experience with:
- Network programming
- Event-driven systems
- Protocol implementation
- High-performance server design
- State management
- Concurrent connection handling
- Defensive programming
- Systems-level debugging