This project consists of a simple chat server and a chat client with a graphical user interface (GUI). The chat server handles incoming connections and broadcasts messages to all connected clients. The chat client connects to the server, allowing users to send and receive messages.
The ChatServer class is a basic server that listens for client connections on port 12345. It handles multiple clients concurrently, broadcasting messages received from any client to all connected clients.
- Accepts multiple client connections.
- Broadcasts received messages to all clients.
- Handles client disconnections gracefully.
- Compile the server code:
javac ChatServer.java
- Run the server:
java ChatServer
The ChatClientGUI class is a Swing-based GUI application that connects to the chat server. Users can send and receive messages, change their nickname, and exit the chat.
- User-friendly GUI for sending and receiving messages.
- Allows users to change their nickname with the
/nick <new nickname>command. - Users can leave the chat using the
/exitcommand.
- Compile the client code:
javac ChatClientGUI.java
- Run the client:
java ChatClientGUI
- Enter the server IP address and port (
12345), and provide a nickname when prompted.
- Server Address: Update the
SERVER_ADDRESSconstant inChatClientGUI.javawith the IP address of the machine running theChatServer. - Port Number: The default port for both server and client is
12345. Change it in both files if needed.
- Java Development Kit (JDK) 8 or later.
This project is licensed under the MIT License.