A simple client-server chat application using Java socket programming. Multiple clients can connect to the server, and messages are broadcast in real-time.
- Multi-client support with separate threads for each client.
- Broadcast messaging to all clients except the sender.
- Automatic client disconnection handling.
- Listens for client connection requests on a specific port.
- Creates a new thread for each client connection using the
ClientHandler
class.
- Manages communication between the server and each client.
- Broadcasts messages from one client to all other clients.
- Handles client disconnection and resource cleanup.
- Sends and receives messages.
- Each client runs on its own thread, with messages broadcast to all connected clients.
- Sending messages is handled by the main thread of the client object.
- listening to messages is handled by a new separate thread.
- Server.java: Initializes
ServerSocket
, accepts connections, and manages threads. - ClientHandler.java: Handles client communication and broadcasting messages.
- Client.java: Sends messages and listens for incoming messages.
-
Clone the repository:
git clone https://github.com/Muhammed-Amer/GroupChat.git cd GroupChat/src
-
Compile the server and client:
javac Server.java javac Client.java
-
Start the server:
java Server
-
In another terminal, run the client: you can make a terminal to each client.
java Client