This project is a simple multithreaded chat application written in C++. It includes a server and a client implementation, allowing multiple clients to connect and exchange messages anonymously.
- Anonymous Communication: Each client is assigned a random unique name upon connection.
- Multithreading: The server handles multiple client connections concurrently.
- Message Broadcasting: Messages sent by one client are broadcast to all other connected clients.
ChatApplication/
├── server/
│ ├── chat_server.cpp
│ ├── Makefile
├── client/
│ ├── chat_client.cpp
│ ├── Makefile
├── README.md
└── LICENSE
- A Linux-based operating system or WSL (Windows Subsystem for Linux).
- A C++ compiler supporting C++11 or later (e.g.,
g++
).
- Navigate to the
server/
directory:cd server
- Compile the server code using the Makefile:
make
- Navigate to the
client/
directory:cd client
- Compile the client code using the Makefile:
make
- Start the server by running the compiled executable:
./chat_server
- The server will start listening for incoming connections on port
8080
by default.
- Start the client by running the compiled executable:
./chat_client
- Enter the IP address of the server when prompted.
- Begin chatting! Messages will be sent with a randomly assigned anonymous name.
- Type
exit
to disconnect from the server.
Server started on port 8080. Waiting for clients...
New client connected.
New client connected.
Received message from client: [AnonUser1]: Hello, everyone!
Received message from client: [AnonUser2]: Hi!
Enter server IP address: 127.0.0.1
Connected to server as AnonUser1. You can start typing messages.
[AnonUser1]: Hello, everyone!
Enter server IP address: 127.0.0.1
Connected to server as AnonUser2. You can start typing messages.
[AnonUser2]: Hi!
- Ensure the server is running before starting the client.
- The default communication port is
8080
. Modify it in the code if needed.
This project is for educational purposes only. It is not intended for use in production environments. Always ensure proper authorization before deploying network applications.
This project is licensed under the MIT License. See the LICENSE file for more details.
Developed by Hector.