Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_irc

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.


Features

  • 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)
  • Graceful client disconnection and cleanup

System Design

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

Concepts Covered

Networking

  • TCP/IP sockets
  • Non-blocking I/O
  • Socket lifecycle
  • Connection management
  • Event multiplexing with poll()

Systems Programming

  • Event-driven architecture
  • File descriptor management
  • Resource cleanup
  • Memory ownership
  • Error handling
  • Graceful shutdown

Protocol Design

  • IRC command parsing
  • Incremental packet buffering
  • Handling fragmented TCP packets
  • Message routing
  • Protocol validation

Software Design

  • Separation of concerns
  • Object-oriented design (C++98)
  • Command dispatcher pattern
  • State management
  • Encapsulation
  • Modular architecture

Concurrency Model

  • Single-threaded event loop
  • Concurrent client handling without threads
  • Fair scheduling through readiness notifications

Engineering Challenges

  • 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

Testing

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

Build

make

Run:

./ircserv <port> <password>

Example:

./ircserv 6667 secret

Tech Stack

  • Modern C++
  • POSIX Sockets
  • poll()
  • Make
  • Linux / macOS

Learning Outcomes

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

About

RFC 1459 Implementation server side in c++

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages