Create an IRC server in C++.
Version: 8
- Introduction
- General rules
- Mandatory part
- Bonus part
- Submission and peer evaluation
IRC is a text-based communication protocol. It supports real-time public and private messages.
IRC clients connect to IRC servers. Servers connect to each other to form a network.
- The program must not crash. It must not quit unexpectedly.
- Turn in a Makefile. It must not relink.
- The Makefile must have these rules:
$(NAME),all,clean,fclean,re. - Compile with C++ and flags:
-Wall -Wextra -Werror. - Use C++ 98 standard.
- Prefer C++ features over C features.
- Do not use external libraries or Boost.
Program name: ircserv
Files to turn in:
- Makefile
*.{h, hpp, *.cpp, *.tpp, *.ipp}- Optional configuration file
Makefile rules:
NAMEallcleanfcleanre
Arguments:
port- The listening portpassword- The connection password
Allowed functions:
socket,close,setsockopt,getsocknamegetprotobyname,gethostbyname,getaddrinfo,freeaddrinfobind,connect,listen,accept,htons,htonlntohs,ntohl,inet_addr,inet_ntoa,send,recvsignal,sigaction,lseek,fstat,fcntl,poll
Do not develop a client. Do not handle server-to-server communication.
Run the program like this:
./ircserv <port> <password>You may use select(), kqueue(), or epoll() instead of poll().
- The server must handle multiple clients at the same time.
- Do not use
fork(). All I/O operations must be non-blocking. - Use only one
poll()(or equivalent) for all operations.
You must use poll() (or equivalent) for all read and write operations. If you read or write without poll(), the server is blocking and you will get a grade of 0.
- Choose one IRC client as a reference.
- Your reference client must connect without errors.
- Use TCP/IP (v4 or v6).
- Implement these features:
- Authentication, nickname, username, join channels
- Send and receive private messages
- Forward channel messages to all members
- Support operators and regular users
- Operator commands:
KICK- Remove a client from a channelINVITE- Invite a client to a channelTOPIC- Change or view the channel topicMODE- Change channel modes:i- Invite-onlyt- Topic restrictionk- Channel passwordo- Operator privilegel- User limit
Write clean code.
MacOS does not implement write() like other Unix systems. You may use fcntl() to set file descriptors to non-blocking mode.
Only use this command:
fcntl(fd, F_SETFL, O_NONBLOCK);Do not use other flags.
Test all possible errors. You can test with nc:
$ nc 127.0.0.1 6667
com^Dman^Dd
$Use ctrl+D to send parts of a command.
Add these features:
- File transfer
- A bot
The bonus part is graded only if the mandatory part is perfect and works without errors.
Turn in your assignment in your Git repository. Only the work in the repository is evaluated.
You may create test programs. Tests are useful for the defense.
Your reference client will be used during evaluation.
SHA checksums:
- 16D85ACC441674FBA2DF65190663F432222F81AA0248081A7C1C1823F7A96F0B
- 15056E97427E5B22F07132659EC8D88B574BD62C94BB654D5835AAD889B014E
- 709F6E