Understanding How a Server Works
As you saw in Chapter 3, Writing a Simple HTTP Client, writing a simple TCP client is mostly straightforward. We have to jump through a few more hoops to make our server work, though, so before we go into the details, let’s take a step back to look at the big picture.
A typical server program does three things:
- It accepts incoming connections on a known TCP port.
- It receives requests from clients.
- It sends back a response to each request.
At first glance this isn’t much different from what a TCP client does. The confounding difference is that a server must perform all these actions at the same time, with an unknown number of uncoordinated clients. Later in this chapter, we’ll use some of the multiprocessing techniques ...
Get Modern Systems Programming with Scala Native now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.