Coding Challenge #101 - Echo Server
This challenge is to build your own Echo server.
Hi this is John with this week’s Coding Challenge.
🙏 Thank you for being one of the 91,229 software developers who have subscribed, I’m honoured to have you as a reader. 🎉
If there is a Coding Challenge you’d like to see, please let me know by replying to this email📧
Coding Challenge #101 - Echo Server
This challenge is to build your own echo server. An echo server is a server that implements the Echo Protocol, as defined in RFC 862. The short version of the protocol is this: the server echoes back to the originating client any data it receives until the connection is terminated.
In case you’re wondering, this is a useful debugging and measurement tool for network engineers. It’s also a great first server to build if you’re learning about network programming and interested in eventually building your own Redis, building your own Memcached or building your own server.
By building your own echo server you’ll learn about:
Using the sockets API of your programming language, specifically how to open a socket, bind it to an address and port, listen for incoming connections and then send and receive data over the network.
TCP and UDP network protocols.
How Internet standards are defined.
New Rust Course Coming January 2026!
After multiple requests I’m launching a new course: Learn Rust With Projects which will teach you Rust by walking you through building five projects.
The course teaches you to write effective and idiomatic Rust by guiding you through the language features, tooling and idioms required to build command line tools, network clients and network servers in Rust.
You’ll learn how to use Rust for network programming, concurrency, test-driven development and building high-performance servers. At the end of it you will have built five real-world applications in Rust: cat, sort, curl, wc and a Memcached server.
The course will be available from January 9th 2026. If you’re interested and want to be kept informed you can sign up for the waitlist here. Everyone on the waitlist will be notified when it’s available and offered a discount.
If You Enjoy Coding Challenges Here Are Four Ways You Can Help Support It
Refer a friend or colleague to the newsletter. 🙏
Sign up for a paid subscription - think of it as buying me a coffee ☕️, with the bonus that you also get 20% off any of my courses.
Buy one of my self-paced courses that walk you through a Coding Challenge.
Join one of my live courses where I personally teach you Go by building five of the coding challenges or systems software development by building a Redis clone.
The Challenge - Building An Echo Server
For this Coding Challenge your goal is to build an echo server that implements all of the Echo Protocol as defined in RFC 862.
By the way, if you prefer you can view the echo server project on the Coding Challenges YouTube channel. Or you can just subscribe to the channel anyway - I’m going to be adding lots more content over the coming year.
If you have suggestions for video that would help you, feel free to get in contact and let me know. Thanks.
Step Zero
As usual this is where you select the programming language you’re going to use for this challenge, set up your IDE and grab beverage of your choice.
Once you’ve done that have a read of the RFC (if you haven’t already) and check if you already have netcat or telnet installed on your system. If not install one or both of them, they’re very useful tools for debugging network servers.
Step 1
In this step your goal is to build a simple server that will start-up, bind to all the local IP addresses, listen on port 7, and accept a TCP connection. To complete this step simply have the server print out a log message to show a connection has been accepted and then have it shutdown. Refer to the documentation for you programming language to find out how to write network programs using it.
You can test your server using two terminals, in one run the server and in the other use netcat or telnet to connect to it. That looks like this:
# Server Terminal
% ccecho
Accepted connection from: 127.0.0.1:63798
% # Client terminal, using netcat
% nc localhost 7Step 2
In this step your goal is to extend your server to accept multiple concurrent connections. This will require you to keep the main ‘thread’ of execution running and listening for incoming connections as well as spawning a new ‘thread’ of execution to handle each client.
Note I’m putting ‘thread’ in quotes here because I’m referring to something that is running concurrently alongside something else. That could be multiple operating system threads or it could be multiple async tasks. Your choice!
You can test your server using two terminals, in one run the server and in the other use netcat or telnet to connect to it. That looks like this:
# Server Terminal
% ccecho
Accepted connection from: 127.0.0.1:63243
Accepted connection from: 127.0.0.1:63245 Note the server stays running now.
Then use two other terminals to connect like this:
# Client terminal, using netcat
% nc localhost 7Step 3
In this step your goal is to read data from the client and write that data back to the client. That should continue until the client terminates the connection.
That will look like this:
# Server Terminal
% ccecho
Accepted connection from: 127.0.0.1:53684
Client disconnected
% # Client terminal, using netcat
% nc localhost 7
Hello, Coding Challenges
Hello, Coding Challenges
^C% Step 4
In this step your goal is to add a command line flag so your echo server can be started up using either TCP or UDP on port 7.
# Server Terminal
% ccecho -udp
UDP Echo server listening on :7
^C% # Client terminal, using netcat -u for UDP, your version may differ
% nc -u localhost 7
Hi Coding Challenges
Hi Coding Challenges
^C% Step 5
In this step your goal is to shutdown cleanly. Ensuring all connections are closed and any inflight echo messages are sent before shutdown.
Going Further
After you’ve built your own echo server you might like to try:
All of which will introduce you to building different aspects of a network server.
P.S. If You Enjoy Coding Challenges Here Are Four Ways You Can Help Support It
Refer a friend or colleague to the newsletter. 🙏
Sign up for a paid subscription - think of it as buying me a coffee ☕️ twice a month, with the bonus that you also get 20% off any of my courses.
Buy one of my courses that walk you through a Coding Challenge.
Subscribe to the Coding Challenges YouTube channel!
Share Your Solutions!
If you think your solution is an example other developers can learn from please share it, put it on GitHub, GitLab or elsewhere. Then let me know via Bluesky or LinkedIn or just post about it there and tag me. Alternately please add a link to it in the Coding Challenges Shared Solutions Github repo
Request for Feedback
I’m writing these challenges to help you develop your skills as a software engineer based on how I’ve approached my own personal learning and development. What works for me, might not be the best way for you - so if you have suggestions for how I can make these challenges more useful to you and others, please get in touch and let me know. All feedback greatly appreciated.
You can reach me on Bluesky, LinkedIn or through SubStack
Thanks and happy coding!
John

