Skip to content

This is my Computer Networks project that uses classes from java.net and java.io package to implement chatroom the functionality.

Notifications You must be signed in to change notification settings

mshirazkamran/client-server-chatroom-CN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Java Socket Chat Application (Multi-Client Server)

🧑‍💻 Subject: Computer Networks

📁 Project Title: Multi-Client Chat using TCP Sockets in Java


📄 Project Overview

This project demonstrates how socket programming works in Java. It allows multiple clients to connect to a server and communicate with each other in real-time. Each client runs on a separate thread, and all messages are broadcast to other connected users.

The project uses:

  • TCP/IP sockets
  • Multithreading
  • Buffered Streams
  • A custom class ClientModeller to manage client info

📂 File Structure

File Name Description
Server.java Main server program to accept and handle clients
Client.java Simple command-line client to connect to server
ClientModeller.java Class to model each client with streams and name

⚙️ How It Works

  1. Server runs on port 1234.
  2. Clients connect to the server and enter their names.
  3. Each client is handled in its own thread.
  4. Messages sent by a client are broadcast to all others.

▶️ How to Run

  1. Compile all files

    javac Server.java Client.java ClientModeller.java
  2. Start the server

    java Server
  3. Start one or more clients (in separate terminals)

    java Client

💬 Example Output

Server

Server started on port 1234
New client connected: /127.0.0.1
Shiraz joined the chat.
Ahmed joined the chat.

Client 1 (Alice)

Enter your name:
Shiraz
Ahmed has joined the chat.
Ahmed: Hello everyone!

Client 2 (Bob)

Enter your name:
Ahmed
Shiraz: Salam Ahmed!

📘 Concepts Used

  • Java Socket API (TCP)
  • Multi-threading for concurrent client handling
  • Buffered I/O Streams
  • Object-oriented design using helper class (ClientModeller)

🔐 Note

This is a basic educational-level project. Advanced features like authentication, encryption, error handling, and GUI are not included but can be added later for improvement.


This project was created for the Computer Networks course to understand how client-server communication works using Java sockets.

About

This is my Computer Networks project that uses classes from java.net and java.io package to implement chatroom the functionality.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages