r/C_Programming • u/11NEWNOW11 • Jul 19 '26
Completed my first larger-scale C project: An RFC compliant IRC server, and would love some feedback!
Hey guys! I am a cs student who has recently shifted his focus to the C language and more lower-level concepts. I have always been really interested in the history of the Internet itself, so an IRC server as a project was something that was always on my list for a learning project, and with this recent shift I figured what better time than the present.
The Project: https://github.com/sdp-io/c-irc-server
This project, at around ~2k lines of code, has been the largest project I have worked on so far. Due to this, I feel that the amount of educational value it has provided to me has been very rich. I think, that for advanced beginners/intermediates, an IRC server such as this would be an incredible choice with the right supplementary resources (which I will share below,) as you must engage with and learn about sockets, I/O buffer management techniques, modularization, and state+memory management, and event polling.
I believe that due to my pre-existing level of interest in IRC servers, I had much more of a drive in learning about the history for the development of IRC. The more I learned, the more I got a decent understanding on the problems that IRC faced in the 90s, leading me to read up on the performance differences between poll() and epoll(), along with the C10k problem that existed due to older servers dedicating a thread for each new user instead of utilizing event loops, leading to memory usage tanking performance.
Fascinated by the poll() and epoll() differences (and wanting to test something I made myself,) I decided to benchmark the server, and attempt to graph performance differences between the two syscalls. Though the performance difference between these two is something that is already well documented, I was unable to find any sort of resource that ran tests and graphed the differences directly. It may be pointless, but I think it's cool, so the graph can be found within the repos README.
If anyone else is interested in trying something similar to this for educational purposes I highly recommend it, and have some resources that could help get you started. For me, I was able to gain most of the pre-requisite knowledge for the networking portion of the project from Beej's Guide to Network Programming, which I have seen mentioned A LOT for projects doing any sort of networking. However, one such resource that is specific to this project that I have never seen mentioned before, is actually the University of Chicago's chirc assignment guide, which does not provide any sort of direct implementation, instead acting as a general compass to orient yourself, I felt it was a very helpful and good quality resource for me.
Finally, as I don't really have anyone else to share this with, I would love for anyone interested to just take a glance, let me know what they think, provide any advice or point out bad habits I might've adopted in my code, or even make your own if it sounds interesting to you, like it was for me!
tl;dr I made an IRC server and would like for you to check out and critique my code!
•
u/AutoModerator Jul 19 '26
Hi /u/11NEWNOW11,
Your submission in r/C_Programming was filtered because it links to a git project.
You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.
While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
4
u/skeeto Jul 19 '26
Neat project! Some build issues due to mismatching prototypes in
network.h:If I
PARTa channel of which I'm not a member it dereferences a null pointer:In the server (UBSan):
Similar issue passing no channel to
JOIN, passing null to%s:Then:
And another with
PRIVMSG. First make a channel:Then message it while not in the channel:
Then:
1
u/mivanchev Jul 19 '26 edited Jul 19 '26
Great work :)
Instead of
write
Define a proper type for the listener in
Your project is over-int-ed.
In
define away_msg as "const char away_msg[static 1]". Do not ever use strdup or any of C stdlib's str* functions. Define and use a custom string type or use a library. Use asserts whenever possible for invariants and bug spotting, do not use them sparingly. If you're going to ignore return values (like with malloc), at least assert the result. Write some tests with Criterion. Use way more macros, a useful one is
Change
you have significant clutter.
Overall verdict: if you're going to write complex code doing non-trivial stuff, take some time to develop a supporting mini-framework instead of relying on C's primitives. They shouldn't be visible at all. Read about domain specific languages and try to develop a mini one for your project.