A high-performance, multi-user chat server implemented in C. This project features a custom shell environment for users, a concurrent networking architecture, and a persistent database backend for managing messages, users, and groups.
The system is designed in three integrated layers:
- Custom Shell & Command Execution: A sophisticated command parser that handles standard UNIX-style execution (
fork+exec), basic pipes (|), and specialized "numbered pipes" for advanced redirection. - Concurrent Socket Networking: A TCP server architecture allowing multiple concurrent clients to connect via
telnetor similar socket clients. - Data Persistence: A structured backend (using file-based or SQL-style logic) to manage user registration, login sessions, mail (messages), and group memberships.
| Directory | Description |
|---|---|
bin/ |
Compiled executable binaries for client-side tools and commands. |
bsrc/ |
Source code for individual command utilities (e.g., mailto, login, createGroup). |
include/ |
Header files (.h) defining data structures, signals, and networking protocols. |
obj/ |
Compiled object files (.o) used during the linking process. |
src/ |
The core server logic divided into db (database), network, and shell. |
tmp/ |
Temporary storage for session buffers and user lists. |
The server provides each connected user with a shell-like interface.
- Command Execution: Uses
fork()andexecvp()to run binaries found in thebin/directory. - Piping: Supports standard piping (
ls | cat). - Numbered Pipes: (As indicated by
exe_numpipe.c) Supports sending command output to a future command in the sequence, allowing complex multi-step workflows.
- TCP/IP Sockets: Built on the standard Berkeley Sockets API.
- Multi-User Support: Handles multiple connections simultaneously using a concurrent execution model (process-per-client or multiplexing).
- Telnet Compatible: No custom client is required; users can connect using standard telnet protocols.
The src/db and bsrc/ modules handle the state of the chatroom:
- User Management:
register,login, andremove. - Messaging:
mailtofor sending messages andlistMail/delMailfor inbox management. - Group Chat: Features to
createGroup,listGroup,addTo(add members), andleaveGroup.
- GCC or Clang compiler
makebuild utility- A Unix-like environment (Linux/macOS)
- MySQL Client Library: Required for database connectivity. On macOS (Homebrew), install via:
brew install mysqlTo compile the server and all associated command binaries:
makeStart the main server process:
./myserver 127.0.0.1 [port]Open a new terminal and connect via telnet:
telnet 127.0.0.1 [port]Once connected, the following commands are available within the shell:
login: Authenticate your session.register: Create a new user account.mailto [user]: Send a message to a specific user.createGroup [name]: Start a new chat group.listGroup: Show all available groups.number: A utility to add line numbers to output (useful for piping).