https://github.com/mshirazkamran/client-server-chatroom-cn
This is my Computer Networks project that uses classes from java.net and java.io package to implement chatroom the functionality.
https://github.com/mshirazkamran/client-server-chatroom-cn
ip java java21 java22 java23 javaio port socket-io socket-programming tcp tcp-client tcp-server tcp-socket
Last synced: about 1 month ago
JSON representation
This is my Computer Networks project that uses classes from java.net and java.io package to implement chatroom the functionality.
- Host: GitHub
- URL: https://github.com/mshirazkamran/client-server-chatroom-cn
- Owner: mshirazkamran
- Created: 2025-06-12T09:56:26.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2025-06-12T10:14:35.000Z (12 months ago)
- Last Synced: 2025-06-12T11:28:09.476Z (12 months ago)
- Topics: ip, java, java21, java22, java23, javaio, port, socket-io, socket-programming, tcp, tcp-client, tcp-server, tcp-socket
- Language: Java
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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**
```bash
javac Server.java Client.java ClientModeller.java
```
2. **Start the server**
```bash
java Server
```
3. **Start one or more clients (in separate terminals)**
```bash
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._