An IRC server implementation in C++98, compatible with both Linux (epoll) and macOS (poll).
It supports multiple clients, authentication, nick/user registration, channel management, private messaging, and channel operator commands.
Written in a group together with https://github.com/michaela811 and https://github.com/denizcaglarcingoz.
Project is compliant with the subject requirements for 42school ft_irc and with IRC Protocol 1993
- Non-blocking event loop:
- Linux → uses
epoll - macOS → uses
poll
- Linux → uses
- Authentication with
PASS,NICK,USER - Channel system with:
JOINPRIVMSG(private or channel messages)INVITEKICKTOPICMODE(+i,+t,+k,+o,+l)
- Proper numeric replies for protocol compliance
- Handles edge cases (buffer limits, malformed input, rapid connects, etc.)
make./ircserv <port> <password>
# Example:
./ircserv 6667 mypass- poll (macOS):
- Scans the full file descriptor set each time.
- Complexity:
O(n)per call.
- epoll (Linux):
- Kernel stores the set of watched FDs and only reports the ready ones.
- Amortized complexity:
O(ready). - Much more scalable for many clients.
Download: HexChat
- Start server:
./ircserv 6667 mypass
- In HexChat → Network List → Add a network:
- Server:
127.0.0.1/6667 - Password:
mypass - TLS: disabled
- Choose a nickname and username
- Server:
- Connect and test:
/join #chan /topic #chan :Hello World /msg #chan hi all /invite othernick #chan /kick #chan othernick :bye
Terminal A
nc -C 127.0.0.1 6667
PASS mypass
NICK alice
USER alice 0 * :Alice
JOIN #chanTerminal B
nc -C 127.0.0.1 6667
PASS mypass
NICK bob
USER bob 0 * :Bob
JOIN #chan
PRIVMSG #chan :hello!{ printf 'com'; sleep 1; printf 'man'; sleep 1; printf 'd\r\n'; } | nc -C 127.0.0.1 6667This simulates sending fragmented input (com + man + d\n).
Or while running nc when you have at least one character in your command line just press Ctrl+D whenever you want.
Control that the server is still running when one of the clients is suspended. In previously created 'alice' and 'bob':
- on the terminal of bob press
Ctrl+Z - send PRIVMSG from alice to bob
- type
fgin bob's terminal to bring him to foreground - all messages sent by alice should arrive to bob
From repo root:
./run_all_edge_tests.shOr run individually:
./test_buffer_limits.sh
./test_malformed.sh
./test_protocol_violations.sh
./test_rapid_connections.sh
./test_special_chars.shThese scripts send crafted input via nc to test edge cases.
- Authors: grignetta, https://github.com/michaela811 and https://github.com/denizcaglarcingoz