Skip to content

Commit fe2aace

Browse files
committed
Refactor stage descriptions for TCP server implementation and PING command support.
1 parent e6195cf commit fe2aace

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

stage_descriptions/base-01-jm1.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
1-
In this stage, you'll implement a TCP server that listens on port 6379.
2-
3-
### TCP (Transmission Control Protocol)
4-
5-
[TCP](https://en.wikipedia.org/wiki/Transmission_Control_Protocol) is the underlying protocol used by protocols like HTTP, SSH, and others you're probably familiar with. Redis also uses TCP for communication between its clients and servers.
6-
7-
Don't worry if you're unfamiliar with the TCP protocol, or what Redis clients & servers are. You'll learn more about this in the next stages.
8-
9-
For this stage, your program should act as a basic TCP server that listens for incoming connections on port 6379.
10-
11-
### Tests
12-
13-
The tester will execute your program like this:
14-
15-
```bash
16-
$ ./your_program.sh
17-
```
18-
19-
It will then attempt to connect to your TCP server on port 6379. If the connection succeeds, you’ll pass this stage.
20-
21-
### Notes
22-
23-
- Port 6379 is the default port used by Redis.
24-
- If you already have a Redis server running on your machine, you’ll see a “port already in use” error. To fix this, stop the existing Redis server before running your code.
1+
Redis servers communicate over TCP, a protocol that enables reliable data exchange between clients and servers. In this stage, you’ll implement a TCP server that listens on port 6379, just like the real Redis.
252

263
{{#reader_is_bot}}
274
- In this stage, you can assume that you only need to handle a single client. We'll get to handling multiple clients & multiple requests per client in later stages.

stage_descriptions/base-02-rg2.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
In this stage, you'll implement support for the [PING](https://redis.io/commands/ping) command.
22

3+
### TCP (Transmission Control Protocol)
4+
5+
[TCP](https://en.wikipedia.org/wiki/Transmission_Control_Protocol) is the underlying protocol used by protocols like HTTP, SSH, and others you're probably familiar with. Redis also uses TCP for communication between its clients and servers.
6+
7+
Don't worry if you're unfamiliar with the TCP protocol, or what Redis clients & servers are. You'll learn more about this in the next stages.
8+
39
### Redis Commands
410

511
Redis clients communicate with Redis servers by sending [commands](https://redis.io/commands/). For each command, a Redis server sends a response back to the client.
612

713
For example:
14+
815
```bash
916
$ redis-cli SET name Alice
1017
OK
1118
```
12-
Here, the client sends a [`SET`](https://redis.io/docs/latest/commands/set/) command to store the key `name` with the value `Alice`. The server responds with `OK`, confirming that the action was successful.
1319

20+
Here, the client sends a [`SET`](https://redis.io/docs/latest/commands/set/) command to store the key `name` with the value `Alice`. The server responds with `OK`, confirming that the action was successful.
1421

1522
Both commands and responses are encoded using the [Redis serialization protocol (RESP)](https://redis.io/docs/latest/develop/reference/protocol-spec/). We'll learn more about this in later stages.
1623

@@ -46,7 +53,7 @@ Your server should respond with `+PONG\r\n`, which is `PONG` encoded as a [simpl
4653
### Notes
4754

4855
- You can ignore the data that the tester sends you for this stage. We'll get to parsing
49-
client input in later stages. For now, you can just hardcode `+PONG\r\n` as the response.
56+
client input in later stages. For now, you can just hardcode `+PONG\r\n` as the response.
5057
- You can also ignore handling multiple clients and handling multiple PING commands in this stage—we'll get to that in later stages.
5158
- The exact bytes your program will receive won't just be `PING`. Instead, you'll receive something like this: `*1\r\n$4\r\nPING\r\n`,
52-
which is the Redis protocol encoding of the `PING` command. We'll learn more about this in later stages.
59+
which is the Redis protocol encoding of the `PING` command. We'll learn more about this in later stages.

0 commit comments

Comments
 (0)