This project implements a simple chat system using UDP sockets, allowing multiple clients to communicate in real time via a central server.
- UDP-based messaging (JOIN, CHAT, LEAVE)
- Server tracks active clients by IP/Port
- Clients operate on two threads (receive + send)
- Clean custom packet format with headers
- Graceful client exit
UDPChatRoom/
├── client/
│ ├── UDPClient.c # UDP client source
│ └── UDPClient # Compiled binary
├── server/
│ ├── UDPServer.c # UDP server source
│ ├── DieWithError.c # Error handling utility
│ └── UDPServer # Compiled binary
├── Makefile
├── .gitignore
└── README.md
make- Compiles
client/UDPClientandserver/UDPServer
To clean up:
make clean./server/UDPServer./client/UDPClientThe client prompts for a nickname, sends a JOIN packet, and starts sending/receiving messages.
| Field | Size | Description |
|---|---|---|
| Type | 2 | 1 = JOIN, 2 = CHAT, 3 = LEAVE |
| Length | 2 | Length of the message (<= 256) |
| Data | ≤256 | Nickname or chat message |
All integer values are sent in network byte order.
Client:
Enter nickname: Alice
[Alice]: Hello everyone!
Server:
Received JOIN from 192.168.0.12:50938 - Alice
Received CHAT from Alice:
Received LEAVE from Alice
This project is open source under the MIT License.
Developed by Amena2026