Skip to content

Terminal-based real-time chat using C++ and POSIX sockets. Supports multiple clients with multithreading, colored user output, and graceful exit (Ctrl+C). Lightweight, runs on Linux with no GUI. Demonstrates concurrency, thread safety, and network communication basics.

Notifications You must be signed in to change notification settings

AnasMultani17/Client-Server-Chat-App-Using-Socket-Programming-In-CPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Client-Server Chat Application in C++

A real-time terminal-based chat application built using C++ and Socket Programming for both Linux-based server and client communication.

πŸš€ Features

  • Multi-client support with concurrent communication via multi-threading
  • Real-time chat system with colored terminal output for different users
  • Graceful exit using signal handling (Ctrl + C)
  • Optimized for low-latency, responsive communication
  • Lightweight and runs entirely in terminal (no GUI dependencies)

🧠 Technologies Used

  • C++
  • POSIX Sockets
  • Multithreading (<thread>, <mutex>)
  • Linux system calls: socket(), bind(), listen(), accept(), connect(), send(), recv()
  • ANSI escape sequences for terminal coloring

πŸ›  How to Run

Compile the Server

g++ server.cpp -o server -pthread

Compile the Client

g++ client.cpp -o client -pthread

Start the Server

./server

Start the Client (in a different terminal)

./client

πŸ“ Note: Both server and client must run on the same machine or within the same network. You can also replace INADDR_ANY with a specific IP if required.

πŸ“‚ File Structure

  • server.cpp - Handles multiple clients, message broadcasting, and client management
  • client.cpp - Connects to server, sends/receives messages with UI feedback

🧩 Concepts Demonstrated

  • Concurrent programming with thread safety
  • Terminal manipulation and formatting
  • Custom protocol for broadcasting messages
  • Use of mutex and signal for safe thread and process control

πŸ“œ License

This project is for educational purposes only. Contributions and forks are welcome!

About

Terminal-based real-time chat using C++ and POSIX sockets. Supports multiple clients with multithreading, colored user output, and graceful exit (Ctrl+C). Lightweight, runs on Linux with no GUI. Demonstrates concurrency, thread safety, and network communication basics.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages