Skip to content

winnerezy/java-terminal-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Chat Application

A simple chat application where multiple clients can connect to a server and exchange messages in real-time. This project consists of a Server and a Client.

The Server listens for incoming connections on a specified port and handles multiple client connections concurrently.
Each Client can send and receive messages from other clients connected to the server.

Features

Real-time messaging between multiple clients.
Each client can send messages that will be broadcasted to all other connected clients.
Simple server-client architecture with socket programming in Java.
Handles user connection, disconnection, and broadcasting of messages to all active clients.

Requirements

Java 8 or higher.

Setup Instructions

  1. Clone the repository

git clone https://github.com/winnerezy/java-terminal-chat.git cd chat-application

  1. Compile and run the Server

    The server listens on port 1234 by default. To run the server, execute the following command in the Server directory:

javac Server.java java Server

The server will print Server is running and waiting for users.. once it starts and will accept incoming client connections. 3. Compile and run the Client

To run the client, execute the following commands in the Client directory:

javac Client.java java Client

The client will first connect to the server at localhost on port 1234. After that, it will ask for a username and allow the user to send messages.

Usage

Server will wait for incoming client connections.

Client will:
    Connect to the server.
    Ask the user to input a username.
    Allow the user to send messages to the server.
    Display any messages received from the server.

All messages sent by a client are broadcasted to all connected clients.

How It Works Server

The server listens for incoming client connections using ServerSocket.
When a client connects, the server assigns a ClientHandler to manage the connection.
The ClientHandler is responsible for receiving messages from a client and broadcasting them to all other connected clients.

Client

The client connects to the server using Socket.
The user can send messages through the console, which are sent to the server and broadcasted to other clients.
The client continuously listens for incoming messages from the server and displays them to the user.

Example Server Output

Server is running and waiting for users.. Client connected: Socket[addr=/127.0.0.1,port=12345,localport=1234] User John connected. [John]: Hello, world! [Jane]: Hi, John! John has left

Client Output

Connected to server Enter your username: John Welcome to the chat, John!!! Enter Your Message

Hello, world!

Known Issues

No support for private messaging.
No user authentication (uses plain text for usernames).
The program assumes all messages are plain text.

Contributions

Feel free to fork the repository, create pull requests, and contribute to improving the project. License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages