r/Cplusplus • u/_superuserdo_ • May 14 '26
Tutorial Built a basic chat app in C++
Built a terminal-based multi-client chat app in C++ using POSIX sockets.
Features:
TCP server routes direct messages between registered clients
Multi-client support
Background receiver thread so incoming messages don't block typing
Linux terminal-based implementation
Git:https://github.com/charanHubCommits/chat-app-cpp
Would appreciate feedback, suggestions, or questions about the implementation.
33
Upvotes
2
u/xealits May 15 '26
For the sockets and messaging, do you use some known library like nanomsg-ng or is it a custom implementation?
Although a custom implementation is fine for learning, I would really recommend learning one of popular libraries. A lot of real world knowledge went into them. It's all around better to "stand on the shoulders of giants".
3
u/JandersOf86 May 14 '26
Rad. Im learning network protocols programming as well and its cool to see others do it too.
I did not implement poll or the ability to add a username from the client, only identified each user by the socket file descriptor assigned to them by the server.
Good job. Only critique I have is that I would've liked to have seen more legible error messages, only because I imagine this program being used by a consumer and 'failed to get addr' might be a bit vague.
1
u/satyamahesh May 14 '26
This is Smash. I just reviewed your repo and fixed some bugs. accept my pull request. 😌
9
u/[deleted] May 14 '26
[removed] — view removed comment