Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ฌ Chat App with Socket Programming (Java)

Java Networking Multithreading GitHub

๐Ÿ”— GitHub Repository:
https://github.com/vyawaha/java-chat-app-socket-programming.git

A real-time client-server chat application built using Java Socket Programming that allows multiple users to communicate simultaneously through TCP sockets.

The project demonstrates practical implementation of:

  • Client-server architecture
  • TCP socket communication
  • Multithreading
  • Real-time message exchange
  • Public broadcasting
  • Private messaging
  • User management
  • Chat history logging

๐Ÿ“Œ Project Overview

Modern applications such as messaging platforms, multiplayer games, customer support systems, collaboration tools, and notification systems rely heavily on real-time communication.

This project implements the fundamental networking concepts behind these systems by creating a centralized Java chat server where multiple clients can connect, communicate, and exchange messages in real time.


๐Ÿ”— Project Information

Category Details
Project Name Chat App with Socket Programming
Language Java
Project Type Networking / Backend Application
Communication TCP Socket Programming
Architecture Client-Server Architecture
Concurrency Multithreading
Storage File Based Chat Logging
Repository https://github.com/vyawaha/java-chat-app-socket-programming.git

๐ŸŽฏ Problem Statement

Design and develop a real-time chat application where:

  • Multiple clients can connect to one server
  • Users can send messages simultaneously
  • Messages are delivered instantly
  • Users can communicate privately
  • Server manages client connections
  • Chat activity is stored for future reference

๐Ÿš€ Features

Core Features

โœ… TCP socket based communication
โœ… Client-server architecture
โœ… Multiple client support
โœ… Real-time message exchange
โœ… Username identification
โœ… Join notification
โœ… Leave notification
โœ… Public message broadcasting
โœ… Private messaging
โœ… Chat history logging
โœ… Graceful client disconnect
โœ… Exception handling


๐Ÿ—๏ธ System Architecture

             Client 1
                |
                |
             Socket
                |
                |
Client 2 ---- Java Chat Server ---- Client 3
                |
                |
        Client Handler Threads
                |
                |
        Message Broadcasting
                |
                |
        Chat History Logger

๐Ÿ”„ Working Flow

Client Starts

      โ†“

Connects to Server using Socket

      โ†“

Server Accepts Connection

      โ†“

Client Handler Thread Created

      โ†“

User Enters Username

      โ†“

Messages Sent To Server

      โ†“

Server Processes Message

      โ†“

Broadcast / Private Delivery

      โ†“

Message Logged

๐Ÿ› ๏ธ Technologies Used

Technology Purpose
Java Programming Language
Socket API Network Communication
ServerSocket Server Connection Handling
Thread Concurrent Client Handling
BufferedReader Reading Input
PrintWriter Sending Output
File Handling Chat Logging
Git/GitHub Version Control

๐Ÿ“š Java Concepts Used

Socket

Used for communication between client and server.

ServerSocket

Used by the server to listen for incoming client connections.

Threads

Each client connection runs independently using a separate thread.

Collections

ArrayList is used to maintain active connected clients.

Synchronization

Used to safely access shared client data.

Exception Handling

Handles network failures and unexpected disconnections.


๐Ÿ“‚ Project Structure

java-chat-app-socket-programming
โ”‚
โ”œโ”€โ”€ src
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ server
โ”‚   โ”‚   โ”œโ”€โ”€ ChatServer.java
โ”‚   โ”‚   โ””โ”€โ”€ ClientHandler.java
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ client
โ”‚   โ”‚   โ””โ”€โ”€ ChatClient.java
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ common
โ”‚       โ””โ”€โ”€ ChatLogger.java
โ”‚
โ”œโ”€โ”€ logs
โ”‚   โ””โ”€โ”€ chat_history.txt
โ”‚
โ”œโ”€โ”€ screenshots
โ”‚
โ”œโ”€โ”€ docs
โ”‚   โ””โ”€โ”€ Testing_Report.md
โ”‚
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ .gitignore

โ–ถ๏ธ How To Run The Project

Requirements

Install:

  • Java JDK 17 or above
  • Git
  • VS Code / IntelliJ IDEA / Eclipse

Check Java:

java -version

Compile Project

From project root:

javac -d out src\common\*.java src\server\*.java src\client\*.java

Start Server

Open Terminal 1:

java -cp out server.ChatServer

Output:

==============================
 Java Chat Server
==============================

Server started successfully.
Listening on port : 5000
Waiting for clients...

Start Client 1

Open Terminal 2:

java -cp out client.ChatClient

Username:

Alice

Start Client 2

Open Terminal 3:

java -cp out client.ChatClient

Username:

Bob

Start Client 3

Open Terminal 4:

java -cp out client.ChatClient

Username:

Charlie

๐Ÿ’ฌ Chat Commands

Public Message

Type:

Hello everyone

Output:

Alice: Hello everyone

Private Message

Format:

@username message

Example:

@Bob Hello Bob

Only Bob receives:

[Private] Alice: Hello Bob

๐Ÿ“ Chat Logging

All messages are stored in:

logs/chat_history.txt

Example:

Alice joined the chat

Bob joined the chat

Alice: Hello everyone

[Private] Alice: Hello Bob

Bob left the chat

๐ŸŽฅ Live Demo / Execution Flow

Demo Steps

  1. Start Java Chat Server
java -cp out server.ChatServer
  1. Connect multiple clients:
Alice
Bob
Charlie
  1. Test communication:
  • Send public messages
  • Send private messages
  • Disconnect users
  • Verify notifications
  • Check chat history

Expected Behavior

Server:

Alice joined the chat
Bob joined the chat

Alice: Hello Bob

[Private] Alice: Hi Bob

Bob left the chat

Client:

Alice: Hello everyone

[Private] Alice: Hi Bob

Chat log:

logs/chat_history.txt

๐Ÿงช Testing

The project was tested with:

Test Case Result
Server startup โœ… PASS
Client connection โœ… PASS
Multiple clients โœ… PASS
Message broadcasting โœ… PASS
Private messaging โœ… PASS
User disconnect โœ… PASS
Chat logging โœ… PASS
Exception handling โœ… PASS

๐Ÿ“ธ Project Screenshots

Phase 1 - Project Structure

Complete project folder organization.

Project Structure

Phase 9 - Server Running and Client Communication

Multiple users communicating through Java socket server.

Running Chat

Phase 9 - Chat History Logging

Stored messages generated by the application.

Chat History

Phase 11 - Multiple Client Testing

Testing communication between multiple users.

Multiple Clients

Phase 11 - Private Messaging

Testing user-to-user private communication.

Private Messaging


๐ŸŒ Industry Relevance

This project demonstrates concepts used in:

  • Messaging applications
  • Multiplayer games
  • Customer support systems
  • Collaboration platforms
  • Real-time notification systems
  • Distributed applications

The same networking principles are used in large-scale backend systems.


๐Ÿ”ฎ Future Improvements

Possible enhancements:

  • Java Swing / JavaFX GUI
  • User authentication
  • Database integration
  • Multiple chat rooms
  • File sharing
  • Message encryption
  • Cloud deployment
  • Online/offline status
  • End-to-end encryption

๐ŸŽ“ Learning Outcomes

Through this project, I learned:

โœ… TCP/IP communication
โœ… Socket programming
โœ… Multithreaded server design
โœ… Client-server architecture
โœ… Real-time communication systems
โœ… Network exception handling
โœ… GitHub project management


๐Ÿท๏ธ GitHub Topics

java
socket-programming
tcp
networking
client-server
multithreading
threads
backend
java-project
console-application
oop
computer-networks
chat-application
server
github-portfolio

๐Ÿ‘จโ€๐Ÿ’ป Author

Muktai Vyawahare

Computer Science Engineering Student

GitHub Portfolio Project


โญ Support

If you like this project, consider giving it a โญ on GitHub.

Explore the implementation of Java networking, socket programming, and multithreaded backend systems.

About

A multithreaded Java Socket Programming project that enables real-time communication between multiple clients through a centralized server with broadcasting, private messaging, user management, and chat logging.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages