[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6346":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":14,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":9,"pushedAt":9,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":15,"starSnapshotCount":15,"syncStatus":17,"lastSyncTime":27,"discoverSource":28},6346,"smallchat","antirez\u002Fsmallchat","antirez","A minimal programming example for a chat server",null,"C",7511,844,116,3,0,1,2,4,39.78,false,"main",true,[],"2026-06-12 02:01:18","# Smallchat\n\nTLDR: This is just a programming example for a few friends of mine. It somehow turned into a set of programming videos, continuing one project I started some time ago: Writing System Software videos series.\n\n1. [First episode](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=eT02gzeLmF0), how the basic server works.\n2. [Second episode](https:\u002F\u002Fyoutu.be\u002FyogoUJ2zVYY), writing a simple client with raw terminal handling.\n\nLikely more will follow, stay tuned.\n\n**IMPORTANT: a warning about PRs**: please note that most pull requests adding features will be refused, because the point of this repository is to improve it step by step in the next videos. We will do refactoring during live coding sessions (or explaining how the refactoring was needed in the video), introducing more libraries to improve the program inner working (linenoise, rax, and so forth). So if you want to improve the program as an exercise, go ahead! It's a great idea. But I will not merge new features here since the point of the program is to evolve it step by step during the videos.\n\n## And now, the full story:\n\nYesterday I was talking with a few friends of mine, front-end developers mostly, who are a bit far from system programming. We were remembering the old times of IRC. And inevitably I said: that writing a very simple IRC server is an experience everybody should do (I showed them my implementation written in TCL; I was quite shocked that I wrote it 18 years ago: time passes fast). There are very interesting parts in such a program. A single process doing multiplexing, taking the client state and trying to access such state fast once a client has new data, and so forth.\n\nBut then the discussion evolved and I thought, I'll show you a very minimal example in C. What is the smallest chat server you can write? For starters to be truly minimal we should not require any proper client. Even if not very well, it should work with `telnet` or `nc` (netcat). The server's main operation is just to receive some chat line and send it to all the other clients, in what is sometimes called a fan-out operation. However, this would require a proper `readline()` function, then buffering, and so forth. We want it simpler: let's cheat using the kernel buffers, and pretending we every time receive a full-formed line from the client (an assumption that is in practice often true, so things kinda work).\n\nWell, with these tricks we can implement a chat that even has the ability to let the user set their nick in just 200 lines of code (removing spaces and comments, of course). Since I wrote this little program as an example for my friends, I decided to also push it here on GitHub.\n\n## Future work\n\nIn the next few days, I'll continue to modify this program in order to evolve it. Different evolution steps will be tagged according to the YouTube episode of my series on *Writing System Software* covering such changes. This is my plan (may change, but more or less this is what I want to cover):\n\n* Implementing buffering for reading and writing.\n* Avoiding the linear array, using a dictionary data structure to hold the client state.\n* Writing a proper client: line editing able to handle asynchronous events.\n* Implementing channels.\n* Switching from select(2) to more advanced APIs.\n* Simple symmetric encryption for the chat.\n\nDifferent changes will be covered by one or more YouTube videos. The full commit history will be preserved in this repository.\n","Smallchat 是一个极简的聊天服务器编程示例。该项目使用C语言编写，核心功能包括处理客户端连接、接收消息并广播给所有在线用户，以及允许用户设置昵称。它通过巧妙利用内核缓冲区简化了输入处理过程，使得整个程序能够在200行左右（去除空格和注释后）实现基础的聊天室功能。特别适合对系统级编程感兴趣的开发者学习网络编程基础及了解如何构建简单的多用户交互应用。此外，项目作者计划通过一系列视频教程逐步改进代码，因此对于希望跟随教程实践提高编程技能的学习者来说是一个很好的资源。","2026-06-11 03:06:35","top_language"]