A lightweight and efficient TCP chat server built with C. This project demonstrates how to handle multiple client connections, broadcast messages, and manage user sessions using C's high-performance networking capabilities.
- 🚀 Blazing-fast TCP server powered by C
- 👥 Multi-user support with real-time message broadcasting
- 🔒 Automatic user registration with nickname validation
- 🔌 Handles disconnections gracefully
- 🎉 Welcomes new users and provides an online user list
Make sure you have C compiler installed on your system.
Clone the repository:
git clone https://github.com/BaseMax/TCP-Chat-C.git
cd TCP-Chat-C
Compile:
gcc main.c -o main
To start the server, run:
./main
By default, the server runs on 127.0.0.1:3000
. You can connect to it using a TCP client like nc
(Netcat):
nc 127.0.0.1 3000
When a client connects, they are prompted to enter a nickname.
If the nickname is unique, they join the chatroom and receive a welcome message.
Messages sent by a user are broadcasted to all other connected clients.
If a user disconnects, a notification is sent to the remaining users.
main.c
- Main entry point of the TCP server
Contributions are welcome! Feel free to fork the repo, create a feature branch, and submit a pull request.
This project is open-source and available under the MIT License.
Copyright 2025, Max Base