A high-performance, concurrent TCP client-server system built in C for managing digital business cards.
Visit Card is a robust networking application that allows multiple clients to simultaneously connect, manage, and query a centralized database of digital business cards. Built entirely in C using the POSIX/Linux API, it demonstrates core systems programming concepts including socket communication, multi-processing, and database integration.
The application follows a classic Client-Server architecture over TCP/IP:
- Concurrent Server: Utilizes the
fork()system call to spawn a new child process for every incoming client connection. This ensures that the server can handle multiple clients concurrently without blocking. - Database Layer: Integrates SQLite3 directly into the server to ensure fast and persistent data storage. It automatically initializes the database and seeds default data on the first run.
- Custom Protocol: Uses a text-based, application-layer protocol for communication, including a challenge-response authentication mechanism for sensitive actions.
- Multi-processing: Non-blocking concurrent client handling via process cloning (
fork()). - Persistent Storage: Full CRUD operations backed by an SQLite database.
- Advanced Search: Filter cards dynamically using keyword matching (similar to a browser's F3 search).
- Security & Authentication: Password-protected commands (
new_card,edit_card,delete_card) to prevent unauthorized modifications. - Automated Setup: The server automatically creates the necessary tables and populates initial records if the database is empty.
- Language: C / C++
- Networking: TCP/IP Sockets (POSIX)
- OS API: Linux Systems Programming (
fork(),read(),write(), file descriptors) - Database: SQLite3 C/C++ Interface
Clients interact with the server using the following commands:
help- Displays the list of available commands.get_cards- Retrieves and displays all business cards.get_card <id>- Retrieves details for a specific card by its ID.search_cards <text>- Searches for cards containing the specified text (e.g., matching a name or email domain).new_card,<Name>,<Address>,<Email>- [Requires Password] Adds a new business card.edit_card,<id>,<Name>,<Address>,<Email>- [Requires Password] Updates an existing card.delete_card <id>- [Requires Password] Removes a card from the database.exit- Safely closes the client connection.
- GCC Compiler
- SQLite3 Library (
libsqlite3-devon Linux) - Linux/Unix Environment (or WSL on Windows)
Compile the server and client components:
# Compile the Server (link SQLite3)
gcc server.c -o server -lsqlite3
# Compile the Client
gcc client.c -o client