Skip to content

Shivansh-22866/chat_application_cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Socket Chat Application

Overview

A simple multi-client chat application implemented in C++ using socket programming and pthreads. The project consists of a server and client that can communicate in real-time.

Features

  • TCP/IPv4 socket communication
  • Multi-client support
  • Threaded message sending and receiving
  • Username-based messaging
  • Broadcast Messaging

Prerequisites

  • C++ compiler with C++11 support
  • POSIX threads (pthread) library
  • Linux/Unix-based system

Project Structure

  • Client.cpp: Client-side implementation
  • Server.cpp: Server-side implementation
  • SocketUtil.hpp: Socket utility header
  • SocketUtil.cpp: Socket utility implementation

Compilation

Compile the server and client separately:

# Compile Server
g++ -std=c++11 Server.cpp -o server -pthread

# Compile Client
g++ -std=c++11 Client.cpp -o client -pthread

Usage

  1. Start the server:
./server
  1. In separate terminals, start multiple clients:
./client
  1. Enter a username for each client
  2. Start messaging
  3. Type exit to disconnect

Key Functions

  • createTCPIpv4Socket(): Creates a TCP IPv4 socket
  • createIPv4Address(): Configures socket address
  • acceptIncomingConnection(): Handles new client connections
  • listenAndDisplay(): Manages message receiving
  • broadcastReceivedMessage(): Sends messages to all connected clients

Limitations

  • Maximum 10 concurrent client connections
  • Basic error handling
  • No encryption or advanced security features

About

A real-time multi-client chat application using C++ socket programming and pthreads.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages