In Part 2 of our Redis CLI project, we take a major step forward by establishing a connection to the Redis server. We implement the connectToServer function using Berkeley sockets, ensuring our CLI can successfully communicate with Redis. Along the way, we introduce a structured project layout with CLI.h, CLI.cpp, RedisClient.h, RedisClient.cpp, and a Makefile for compilation.
🔹 Topics Covered:
✅ Created project structure: CLI and RedisClient classes
✅ Implemented connectToServer to establish a TCP connection
✅ Updated main.cpp to integrate connection testing
✅ Compiled and tested using Makefile
📌 Source Code:
https://github.com/Cukowski/Redis-CLI
🔔 Stay tuned for the next part where we handle command formatting and sending requests to Redis!
Timestamps:
0:00 - Introduction & recap of Part 1
1:45 - Setting up project structure
2:45 - Creating CLI class, CLI.h, CLI.cpp
9:15 - Crating RedisClient class, RedisClient.h, RedisClient.cpp
15:30 - Writing the connectToServer function
16:20 - Using Berkeley sockets to establish a connection
19:30 - Handling IPv4 and IPv6 using getaddrinfo
30:40 - Creating and using a Makefile for compilation
32:10 - Updating main.cpp to test the connection
32:30 - Running tests and verifying Redis connection
34:30 - Summary & what’s next