https://github.com/kouroshtkk/poll-tcp-db-server-client
Tcp Client-Server written in C with poll IO multiplexing with add, remove, update and list functionality.
https://github.com/kouroshtkk/poll-tcp-db-server-client
c client-server database employee employee-management network network-programming socket-io socket-programming tcp
Last synced: about 1 month ago
JSON representation
Tcp Client-Server written in C with poll IO multiplexing with add, remove, update and list functionality.
- Host: GitHub
- URL: https://github.com/kouroshtkk/poll-tcp-db-server-client
- Owner: kouroshtkk
- License: mit
- Created: 2025-08-23T15:56:07.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-08-23T16:22:40.000Z (about 2 months ago)
- Last Synced: 2025-08-24T06:12:14.189Z (about 2 months ago)
- Topics: c, client-server, database, employee, employee-management, network, network-programming, socket-io, socket-programming, tcp
- Language: C
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Poll-based TCP Employee Database (C)
This project implements a simple TCP **client-server employee database** in C using `poll()` for I/O multiplexing.
The server supports multiple clients, and the client can perform add, update, remove, and list operations. The server saves the database on shutdown.---
# Project Structure
├── src/│ ├── srv/ # Server source files
│ └── cli/ # Client source files
├── obj/ # Object files (created during build)
├── bin/ # Compiled server and client binaries
├── include/ # Header files
├── Makefile
└── README.md
# Building
Make sure you have `gcc` installed. Then simply run:
```bash
make
```
# Running the server
```bash
./bin/dbserver -p -f
```
if you want to use a new database file add the tag -n afterTo gracefully shut down the server and save the database, press Ctrl-C. The servers handle the shutdown using shutdown_pipe.
# Running the client
```bash
./bin/dbcli -p -h [options]
```
the server is set on localhost meaning 127.0.0.1 in port 5555, you can change this manually in the program with whatever IP you want.# [options]
Add an Employee:
```bash
./bin/dbcli -p 5555 -h 127.0.0.1 -a "name,address,age"
```
Update an employee:
```bash
./bin/dbcli -p 5555 -h 127.0.0.1 -u "current_name,new_address,new_age"
```
Remove an employee:
```bash
./bin/dbcli -p 5555 -h 127.0.0.1 -r "name,address,not important but int would be better or simply 0"
```
List all employees:
```bash
./bin/dbcli -p 5555 -h 127.0.0.1 -l
```# Notes
Server uses poll() for efficient multi-client handling.
Database is automatically saved when the server is shut down with Ctrl-C.
Maximum supported clients: 256. (don't change it or you have to change max fds and also client memory allocation, and lots of edits in poll_loop).