Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

01: TCP echo

The smallest possible Redis-shaped server. It binds a port, accepts one connection at a time, reads bytes, and writes the same bytes back.

Why we start here

Before we worry about the Redis protocol (RESP), data structures, or persistence, we prove that the network layer works. If the echo server can hold a conversation with nc, the foundation is solid.

Run it

make 01-tcp-echo

In another terminal:

nc localhost 6380
> hello
< hello
> ping
< ping

What to observe

  • The server prints [recv] for every chunk of data
  • Closing nc with Ctrl+D prints [conn] disconnected
  • A second client cannot connect while the first is active. Try opening two nc sessions to see the queue.

Files

File Purpose
server.py The runnable echo server
GUIDE.md How sockets work, why this is single-client
EXERCISES.md Variations to stretch the idea

What's next

Step 2 adds the RESP wire format so the server understands real Redis commands instead of raw bytes.