Skip to content

prasu-baran/ChatWave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatWave

Overview

ChatWave is a terminal chat application written in C using socket programming. It supports two concurrency models — POSIX threads and the select() system call — for handling multiple clients simultaneously. Private messages, group chats, and file transfer are all supported. Messages and files are client-side encrypted before transmission, so nothing is readable on the wire. See the Features section for the full list.

Building

Requires GCC and pthreads (Linux / WSL recommended).

gcc -Wall -o serverThread serverThread.c -lpthread
gcc -Wall -o clientThread clientThread.c -lpthread
gcc -Wall -o server      server.c
gcc -Wall -o client      client.c -lpthread

Using Threads

serverThread.c and clientThread.c use a dedicated POSIX thread per client.

Start the server:

./serverThread <port>

Connect a client:

./clientThread <host> <port> <username>

Using Select

server.c and client.c use the select() system call to multiplex all connections in a single loop.

Start the server:

./server <port>

Connect a client:

./client <host> <port> <username>

A log file chat_logs/<username>.log is created for every client session. All received messages are written there after decryption.

Message Format

Action Command
Private message @username <message>
Send file @username @file <filename>
Report a user #username
Create group $CREATE <groupname>
Join group $JOIN <groupname>
Leave group $LEAVE <groupname>
Send group message $<groupname> <message>
List all clients SHOW_ALL_CLIENTS
List all groups SHOW_ALL_GROUPS
Disconnect EXIT

Server admin commands (type in the server terminal)

Command Effect
REMOVE <username> Force-disconnect a client
DELETE <groupname> Delete a group
CLOSE Shut down the server

Features

  • Handles up to 10 clients and 10 groups concurrently
  • Unique username enforcement — duplicate connections are rejected
  • Private messaging between any two connected clients
  • Broadcast messaging to all active clients
  • File transfer between clients (first line of file is transferred)
  • Client-side encryption: messages are reversed and encoded as 3-digit ASCII before sending
  • Client reporting system — clients kicked automatically when report threshold is reached
  • Server-controlled client removal (REMOVE <username>)
  • Configurable idle timeout (clients disconnected after inactivity)
  • Group chat:
    • Create, join, and leave groups
    • Group messages delivered to all members except the sender
    • Empty groups are automatically cleaned up

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages