r/C_Programming • u/frizzy67 • Jun 19 '26
Project A shi**y group chat application, my first C project
https://github.com/ievanpoikka/ChatexI'm fairly new to the world of C and application programming. I am trying to learn more about how network programming and multithreading works in C (and in general) so I made this hella buggy group chat application (inspired from https://github.com/masoudy/CSocket )
It has quite a few bugs, sometimes the server randomly crashes with a SIGPIPE, sometimes it refuses a client connection when the usernames have a few characters in common in the beginning. The client bugs out when server refuses the connection and prints random amounts of "You [name]: " strings before exiting.
I'm pretty sure there are a few memory leaks but I'm not exactly sure how to test for themðŸ˜
Can you guys please critique my code give me an honest opinion...? I will really appreciate it, thanks!
Edit: I had merged the multithreading branch but forgot to push it to github, my bad ðŸ˜, just did it now, I'm sorry for making you guys review my old code
15
u/TheOtherBorgCube Jun 20 '26
send()on aSOCK_STREAMcan return any positive length up to and including the amount you requested. It's up to you to callsendagain with the remainder of the buffer.Eg, you try to send "hello world",
sendreturns 3 means it senthel, andlo worldis still in the buffer to be sent.If
recvcompletely filled the buffer, then this is an out of bounds access.5
u/Big-Rub9545 Jun 20 '26
Have you tried Valgrind for the memory leaks?
0
u/MyNameIsHaines Jun 20 '26
4 years ago?