A simple TCP-based chat application with multithreading support, implementing all required features from the project rubric.
-
Get Friend List and Status (1 point)
- Display list of users and their online/offline status
-
Send and Receive Messages (1-1) (1 point)
- Real-time 1-1 chat between two users
-
Disconnect (1 point)
- When a user leaves a conversation, the system notifies the other party
-
Create Group Chat (1 point)
- Allows users to create new group chats
-
Add Users to Group Chat (1 point)
- Group creator can invite more members
-
Remove Users from Group Chat (1 point)
- Group administrators can remove members from the group
-
Leave Group Chat (1 point)
- Users can leave groups they are participating in
-
Send and Receive Messages in Group Chat (1 point)
- Supports sending messages to all members in the group
-
Send Offline Messages (1 point)
- Saves messages when the recipient is not yet online
-
Log Activity (1 point)
- Records all user activity for review
-
Search Chat History (1 point)
- Allows searching old messages by keyword
-
Send Emoji (1 point)
- Supports emojis in messages
-
Set Group Nickname (0.5 points)
- Rename group chat
-
Block User (1 point)
- Block users
-
Pin Message in Conversation (0.5 points)
- Pin messages in chat segment
- Server: Multithreaded TCP server handling multiple client connections
- Client: TCP client with separate receive thread for real-time messaging
- Protocol: Custom text-based protocol for communication
- Storage: File-based storage for messages and activity logs
# Using MinGW
make
# Or compile manually
gcc -Wall -Wextra -std=c11 -o server.exe server.c common.c -lws2_32
gcc -Wall -Wextra -std=c11 -o client.exe client.c common.c -lws2_32make
# Or compile manually
gcc -Wall -Wextra -std=c11 -o server server.c common.c -pthread
gcc -Wall -Wextra -std=c11 -o client client.c common.c -pthread-
Build the project:
make
-
Start the server (in one terminal):
# Windows server.exe # Linux ./server
You should see:
Server started on port 8080 -
Start a client (in another terminal):
# Windows client.exe # Linux ./client
To connect to a remote server:
client.exe 192.168.1.100 -
Use the menu to register, login, and chat!
See QUICKSTART.md for detailed step-by-step instructions and examples.
- Register: Create a new account with username and password
- Login: Login with your credentials
- Get Friends: View your friend list and their online status
- Send Message: Send 1-1 messages to other users
- Create Group: Create a new group chat
- Group Operations: Add/remove members, send group messages
- Search: Search through chat history
- Block/Unblock: Manage blocked users
- Pin Messages: Pin important messages in groups
server.c/server.h: Server implementationclient.c/client.h: Client implementationcommon.c/common.h: Shared utilities and data structuresMakefile: Build configurationactivity.log: Activity log file (created at runtime)messages.txt: Message storage file (created at runtime)account.txt: Simple username/password persistence (one account per line:username password). The server loads this file at startup and appends new accounts on successful registration.
The application uses a custom text-based protocol:
CMD:<command_type>|SENDER:<username>|RECIPIENT:<recipient>|CONTENT:<content>|EXTRA:<extra_data>|TYPE:<message_type>|PINNED:<0|1>|
- The server supports multiple concurrent clients using multithreading
- Messages are stored in
messages.txtfor persistence - Activity logs are written to
activity.log - Offline messages are stored and can be retrieved when users come online
- Group administrators can manage group members and settings