mshirazkamran/client-server-chatroom-CN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation


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 NameDescription
Server.javaMain server program to accept and handle clients
Client.javaSimple command-line client to connect to server
ClientModeller.javaClass to model each client with streams and name

  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.

  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

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!

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

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