rahulpathak-github / linux-socket-chat

A simple chat application implemented in C++ using linux sockets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linux Socket Chat

A simple chat application with client-server architecture, written in C++ using linux socket programming and multithreading

Overview

  • One server, multiple clients
  • Clients can connect to the server and either send connection request to other free clients or wait and accept a connection request
  • One mutex mapped to each client
  • While attempting to connect with another client, the connecting client acquires its own mutex and then the other client's to ensure that concurrency issues are handled well while connecting
  • Paired clients release the acquired mutex on disconnecting

Setup and use locally

  1. Clone the repo and change directory
cd linux-socket-chat
  1. Compile the server.cpp and client.cpp files
g++ server.cpp -o server -lpthread
g++ client.cpp -o client -lpthread
  1. Run the server
./server
  1. Run the clients
./client

Commands

Command

Use

menu show list of supported commands
stats show list of clients with their FDs and status { FREE, BUSY }
connect *CLIENT_FD* pair with (connect to) client identified by CLIENT_FD
goodbye unpair with a connected client
close disconnect from server

About

A simple chat application implemented in C++ using linux sockets


Languages

Language:C++ 100.0%