This project implements a simple chat application comprising a C++ server and a C++ client. The server is capable of handling multiple client connections simultaneously, facilitating real-time message exchange between connected clients. The application uses sockets for communication between the server and clients.
Chat-Application/
├── chat_server.cpp
├── chat_client.cpp
├── CMakeLists.txt
├── Makefile
├── .gitignore
├── LICENSE
└── README.md
- Multi-client Support: The server can handle multiple clients simultaneously, enabling real-time communication between users.
- Real-time Messaging: Clients can send and receive messages in real-time.
- User Identification: Each client provides a username upon connection, which is displayed with their messages.
- Timestamped Messages: Messages are timestamped to show when they were sent.
- C++ compiler (GCC, Clang, or MSVC)
- CMake (for CMake build)
-
Clone the repository:
git clone https://github.com/Vikranth3140/Chat-Application-Terminal.git cd Chat-Application
-
Choose a build method: You can build the project using either CMake or a Makefile.
-
Create the build directory and compile the project:
mkdir build cd build cmake .. make
-
Run the server:
./chat_server
-
Run the client:
./chat_client
-
Compile the project:
make
-
Run the server:
./chat_server
-
Run the client:
./chat_client
- Start the Server: Ensure the server is running by executing
./chat_server
as described above. - Connect Clients: Open multiple terminals and run the client in each terminal to simulate multiple users. Execute
./chat_client
in each terminal. - Enter Username: Each client will prompt for a username upon connection.
- Start Chatting: Begin sending and receiving messages. Each message will be timestamped and display the sender's username.
-
Start the Server:
./chat_server
Output:
Server started on port 8080
-
Connect Clients:
./chat_client
Output:
Connected to server Enter your username: user1
-
Send and Receive Messages:
- Client 1 (
user1
):Hello, everyone!
- Client 2 (
user2
):Hi user1!
- Server output:
Client connected: user1 Client connected: user2 Received message: [12:34:56] user1: Hello, everyone! Received message: [12:35:01] user2: Hi user1!
- Client 1 (
- chat_server.cpp: The C++ server code that handles multiple clients, manages message broadcasting, and timestamps messages.
- chat_client.cpp: The C++ client code that connects to the server, sends messages, and displays incoming messages.
- CMakeLists.txt: CMake configuration file for building the project.
- Makefile: Makefile for building the project.
This project is licensed under the MIT License.