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.
- TCP/IPv4 socket communication
- Multi-client support
- Threaded message sending and receiving
- Username-based messaging
- Broadcast Messaging
- C++ compiler with C++11 support
- POSIX threads (pthread) library
- Linux/Unix-based system
- Client.cpp: Client-side implementation
- Server.cpp: Server-side implementation
- SocketUtil.hpp: Socket utility header
- SocketUtil.cpp: Socket utility implementation
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
- Start the server:
./server
- In separate terminals, start multiple clients:
./client
- Enter a username for each client
- Start messaging
- Type exit to disconnect
- 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
- Maximum 10 concurrent client connections
- Basic error handling
- No encryption or advanced security features