Chapter 3
Writing a Simple HTTP Client

Now that we’ve covered the basics of input and output, we can turn to the most essential domain of modern systems programming: networking. Twenty years ago, when most programs still worked with local files or local databases, this wasn’t necessarily the case. But, as the internet continues to become pervasive in our daily lives, software that doesn’t use a network is almost unheard of.

In this chapter, you’ll learn about the fundamental building blocks that allow computers to communicate over the internet and build a working HTTP client from the ground up. After a quick review of the basics of networking, I’ll cover all the essential OS facilities and system calls and then I’ll show you how to put those pieces together to create a minimal, generic TCP client. Then, you’ll learn how other protocols layer on top of TCP; we’ll add capabilities until you have a working HTTP client library suitable for interacting with remote APIs.