Skip to content

Latest commit

 

History

124 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Computer_Networks_Chat_Application


Overview

This is a multi-client chat application implemented in C++ using a server-client model. The server supports multiple clients and allows broadcasting, private messaging, and client management features using POSIX sockets and multithreading.


Features

Multi client support:

  • Supports up to 5 simultaneous clients (configurable via MAX_CLIENTS)
  • Extra clients are automatically closed

Non-blocking I/O with select():

  • Uses select() to manage new connections and client communications, eliminating the need for multithreading on the server side

Client Alias Management:

  • Each client must set an alias. If an alias is already taken, the server prompts the client for another alias.

Chat Room Join/Leave Mechanism

  • Clients must explicitly join the chat room using the CONNECT command
  • Users can send broadcast or private messages in the chat room

Broadcast Messaging:

  • Messages sent without a command are broadcast to all clients in the chat room

Private Messaging:

  • Prefix a message with @username to send a private message to one or more specific users
  • The sender receives a notificationIf the recipient is not found

DISCONNECT and EXIT:

  • Commands to leave the chat room or close the connection respectively

Customized terminal:

  • ncurses library used for custom terminal with seperate chat and input window, along with scroll option in chat
  • All client terminal related functions are included in terminal.h header file
  • Collission avoided between inputs and outputs due to asynchronous behaviour

Multithreading:

  • Threaded client handling in server for scalability and asynchronous inputs and outputs
  • Threaded input and output handlers in client for ansynchronity

Technologies Used

  • C++ (Standard Library, POSIX APIs)
  • Sockets (TCP/IP)
  • pthreads for multithreading
  • ncurses library for customized terminal
  • ANSI escape sequences for colored terminal output

Compilation

Compiling server

g++ server.cpp -o server -lpthread

Compiling serverSelect

g++ serverSelect.cpp -o server

Compiling client

g++ client.cpp -o client -lpthread -lncurses make sure client.cpp and terminal.h are in the same directory


USAGE

Starting the server

Run the server with a specified port number:

./server <port_number>

Example:

./server 4761

Connecting clients

Run the client and specify the server IP and port:

./client <server_ip> <port_number>

Example:

./client 127.0.0.1 4761


Commands

Command Description
CONNECT Connects the user to the chatroom
DISCONNECT Disconnects the user from the chatroom
EXIT Exits the chat application
@username <message> Sends a private message to a user
<message> Broadcasts a message to all connected users except the sender


SAMPLE IMAGES

Server

serverImage

First Client

client1Image

Second Client

client1Image

Third Client

client3Image

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages