This project is inspired by the "Build Your Own Redis with C/C++" guide. It aims to break down and implement essential features of an in-memory key-value store.
- Hands-on learning: Build an understanding of systems programming with C, focusing on socket communication, memory management, data structures, and efficient client-server protocols.
- Feature staging: Develop in incremental stages to gradually introduce network protocols, command handling, and storage techniques
-
TCP Server-Client Communication:
- The server and client communicate using a structured message protocol, with each message prefixed by a 4-byte length header.
- The server listens on a specified port, accepts multiple requests per client connection, and returns structured responses.
-
Error Handling and Debugging:
- Expanded error handling to manage socket errors, unexpected disconnections, and message size validations.
- Helper functions provide consistent logging and error messages for ease of debugging.
- C Compiler: Required for building the code
- Linux Environment: The project is currently developed on Linux for compatibility with networking libraries.
git clone https://github.com/havl-code/my-redis.git
cd my-redis
- Compile the code:
gcc -o server server.c
gcc -o client client.c
- Run the server:
./server
- Run the client in a new terminal:
./client
The client will send a message to the server and receive a response.
- server.c: Contains the server code with modular handling of client requests, structured message protocol, and multi-request capability per client connection.
- client.c: Implements the client code with multiple requests to the server, modular query handling, and complete data transmission with helper functions.
This project is based on concepts and code from the "Build Your Own Redis with C/C++" guide.