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.
- Supports up to 5 simultaneous clients (configurable via MAX_CLIENTS)
- Extra clients are automatically closed
- Uses select() to manage new connections and client communications, eliminating the need for multithreading on the server side
- Each client must set an alias. If an alias is already taken, the server prompts the client for another alias.
- Clients must explicitly join the chat room using the CONNECT command
- Users can send broadcast or private messages in the chat room
- Messages sent without a command are broadcast to all clients in the chat room
- 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
- Commands to leave the chat room or close the connection respectively
- 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
- Threaded client handling in server for scalability and asynchronous inputs and outputs
- Threaded input and output handlers in client for ansynchronity
- C++ (Standard Library, POSIX APIs)
- Sockets (TCP/IP)
- pthreads for multithreading
- ncurses library for customized terminal
- ANSI escape sequences for colored terminal output
g++ server.cpp -o server -lpthread
g++ serverSelect.cpp -o server
g++ client.cpp -o client -lpthread -lncurses
make sure client.cpp and terminal.h are in the same directory
./server <port_number>
./server 4761
./client <server_ip> <port_number>
./client 127.0.0.1 4761
| 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 |



