A simple online chat application implemented in Java using socket programming. It allows multiple users to connect to a central server and send messages to and receive messages from other users.
- Multiple clients can connect to the server.
- Each client is assigned a unique user ID.
- Clients can send messages to the server, which broadcasts them to all connected clients.
- A simple text-based user interface for entering and viewing messages.
- Java Development Kit (JDK) 8 or higher.
- An IDE or text editor to edit and run the code (optional).
Follow these instructions to get your chat app up and running on your local device.
Copy the repository to your local machine using the following command:
git clone https://github.com/QUANTA-X/CHAT-APPLICATION.git
cd chat-application
Compile the server and client code using the following commands:
javac ChatServer.java
javac ChatClient.java
Start the server by running the following command:
java ChatServer
The server will start and wait for clients to connect. Client Operation
Open new terminal windows or command prompts and run the clients using the following command:
java ChatClient
A welcome message will be displayed asking the user to say hello.
After the server and clients are running, you can start writing messages in each client window. Messages sent from one client will be broadcast to all other connected clients. Each message will begin with the sender's User ID to identify them.
Here is an example of how the application might look in the terminal: Server Output
Welcome everyone to the chat application!
The server started on port 12345.
Waiting for clients to connect...
User1 has joined the chat.
User2 has joined the chat.
Received a message from User1: hey!
Received a message from User2: hi!!
Client Output
Welcome to the chat room! Say hello to your friends!
User1: hey!
User2: hi!!
Troubleshooting
If you encounter issues, please check the following:
Ensure that the server is running before clients start.
Verify that the server and clients use the correct and accessible IP address.
Check your firewall settings to allow the application to use the specified port.