In this chapter, you will delve deep into TCP and HTTP communications using Rust. These protocols are generally abstracted away for developers through the higher-level libraries and frameworks that are used to build web applications. So why is it important to discuss low-level protocols? This is a fair question.
Learning to work with TCP and HTTP is important because they form the foundation for most communications on the internet. Popular application communication protocols and techniques such as REST, gRPC, and WebSockets use HTTP and TCP for transport. Designing and building basic TCP and HTTP servers in Rust will give you the confidence to design, develop, and troubleshoot higher-level application backend services.
However, if you are eager to get started with the example application, you can move ahead to chapter 3 and come back to this chapter when you want to understand more.
- How to write a TCP client and server.
- How to build a library to convert between TCP raw byte streams and HTTP messages.
- How to build an HTTP server that can serve static web pages (a web server) as well as JSON data (a web service). You’ll test the server with standard HTTP clients such as the cURL (command line) tool and a web browser.