Skip to content

Chatroom Application (C++) A simple, real-time chatroom application built using C++. Supports multiple users, message broadcasting, and basic networking features using sockets. Ideal for learning socket programming and building collaborative applications.

License

Notifications You must be signed in to change notification settings

dhanraj-12/ShellChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Room Application

Description

The Chat Room Application is a simple multi-client chatroom built entirely in C++. It allows multiple users to communicate in real-time within a local network or remotely via cloud hosting. This project utilizes C++'s built-in socket libraries for networking and multithreading for handling multiple client connections simultaneously.

Features

  • Multiple Clients: Supports multiple users chatting concurrently.
  • Public and Private Room Mechanism: Users can join public rooms freely or create their own public or private chat rooms.
  • Room Selection and Creation: Users can select from available public rooms or create a new room. Private rooms require a unique private key for access, which must be shared by the room creator.
  • Message Broadcasting: Messages from one client are sent to all other connected clients within the same room.
  • Threaded Client Handling: Each client is managed in its own thread for smooth communication.
  • Client Disconnection Handling: Removes disconnected clients and continues broadcasting messages for active users.

Technologies Used

  • C++ Standard Library Sockets (<sys/socket.h>, <netinet/in.h>, etc.)
  • Multithreading with the C++ Standard Library's thread

Architecture

The following diagram shows the architecture of the Chat Room Application, illustrating the flow of creating and joining public and private rooms:

Chat Room Architecture

How it Works

Server

The server listens for incoming client connections on a specified port (e.g., 8080). When a client connects, the server starts a new thread to handle communication with that client. Messages received from any client are broadcast to all other connected clients.

Client

Each client connects to the server using a socket. Once connected, clients can send and receive messages. Clients can exit the chat by typing quit, which closes their connection to the server.

Requirements

  • A Linux-based system (can be adapted for Windows with minor changes)
  • C++ compiler (e.g., g++)
  • Basic understanding of networking (TCP/IP)

Installation

Step 1: Clone the Repository

git clone https://github.com/your-username/chat-room-application.git
cd chat-room-application

Step 2: Compile the Code

g++ server.cpp -o server -lpthread
g++ client.cpp -o client

Step 3: Run the Server

./server

Step 4: Run the Client

./client

Known Issues

  • Clients may experience slight delays in message broadcasting with a large number of users.
  • Server performance can be affected by very high traffic.

Contributing

Contributions are welcome! Feel free to fork the repository, make changes, and submit pull requests.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

Chatroom Application (C++) A simple, real-time chatroom application built using C++. Supports multiple users, message broadcasting, and basic networking features using sockets. Ideal for learning socket programming and building collaborative applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages