Simple Chat Server & Client: Java app enabling real-time communication between server & multiple clients using Swing GUI. Easy-to-use & efficient.
# Chat Server and Client Application
This is a simple Chat Server and Client application implemented in Java. The project consists of two separate Java programs - a server program and a client program - that enable communication between a server and multiple clients in a chat-like manner.
## Features
- Allows real-time communication between the server and multiple clients.
- Supports text-based messages.
- Each message sent by a client is displayed on both the server and the other connected clients.
- The server and client interfaces are built using Swing GUI components.
- The server can handle multiple client connections simultaneously using threads.
## Requirements
- Java Development Kit (JDK) version 8 or above.
## Platform Used
- Visual Studio IDE (Integrated Development Environment) was used to develop and manage the project.
## How to Run the Project
1. Clone or download the project files from the repository.
2. Open Visual Studio IDE and import the project into the workspace.
3. Build the project to ensure that there are no compilation errors.
4. Run the server:
- Locate the `MyServer` class within the project.
- Right-click on the class, and then click "Run As" > "Java Application."
- The server application will start, and it will display "Server is ready to accept connections" on the console.
5. Run the client:
- Locate the `MyClient` class within the project.
- Right-click on the class, and then click "Run As" > "Java Application."
- A client application window will appear, labeled "Server Chat."
- Type messages in the input text field at the bottom of the window and press "Enter" to send messages to the server and other connected clients.
- The messages from the server and other clients will be displayed in the chat area.
6. To connect multiple clients, repeat step 5 to run additional instances of the `MyClient` class.
## Usage
- The server application provides the central communication hub for the connected clients. All messages are sent to the server first and then relayed to other connected clients.
- Each client can send messages by typing them in the input text field and pressing "Enter."
- To end the chat, a client can type "exit" (without quotes) in the input field. The server and other clients will be notified that the chat has been terminated by that specific client.
## Note
- For simplicity, the project assumes that the server and clients are running on the same machine and communicating through the localhost (127.0.0.1) on port 7777.
- The project uses Swing for the graphical user interface (GUI), which may not be the most optimal choice for a production-level application. However, it serves as a basic demonstration of the client-server architecture and real-time communication. For a more advanced chat application, consider using modern web technologies or JavaFX for a richer user experience.
Submitted by Pranav Bhargava (pranavb001)
Download packets of source code on Coders Packet
Comments