feat: added cleanscript
This commit is contained in:
43
ch21/ch21-00-final-project-a-web-server.html
Normal file
43
ch21/ch21-00-final-project-a-web-server.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Final Project: Building a Multithreaded Web Server</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="final-project-building-a-multithreaded-web-server"><a class="header" href="#final-project-building-a-multithreaded-web-server">Final Project: Building a Multithreaded Web Server</a></h1>
|
||||
<p>It’s been a long journey, but we’ve reached the end of the book. In this
|
||||
chapter, we’ll build one more project together to demonstrate some of the
|
||||
concepts we covered in the final chapters, as well as recap some earlier
|
||||
lessons.</p>
|
||||
<p>For our final project, we’ll make a web server that says “Hello!” and looks like
|
||||
Figure 21-1 in a web browser.</p>
|
||||
<p>Here is our plan for building the web server:</p>
|
||||
<ol>
|
||||
<li>Learn a bit about TCP and HTTP.</li>
|
||||
<li>Listen for TCP connections on a socket.</li>
|
||||
<li>Parse a small number of HTTP requests.</li>
|
||||
<li>Create a proper HTTP response.</li>
|
||||
<li>Improve the throughput of our server with a thread pool.</li>
|
||||
</ol>
|
||||
<img alt="Screenshot of a web browser visiting the address 127.0.0.1:8080 displaying a webpage with the text content “Hello! Hi from Rust”" src="../img/trpl21-01.png" class="center" style="width: 50%;" />
|
||||
<p><span class="caption">Figure 21-1: Our final shared project</span></p>
|
||||
<p>Before we get started, we should mention two details. First, the method we’ll
|
||||
use won’t be the best way to build a web server with Rust. Community members
|
||||
have published a number of production-ready crates available at
|
||||
<a href="https://crates.io/">crates.io</a> that provide more complete web server and
|
||||
thread pool implementations than we’ll build. However, our intention in this
|
||||
chapter is to help you learn, not to take the easy route. Because Rust is a
|
||||
systems programming language, we can choose the level of abstraction we want to
|
||||
work with and can go to a lower level than is possible or practical in other
|
||||
languages.</p>
|
||||
<p>Second, we will not be using async and await here. Building a thread pool is a
|
||||
big enough challenge on its own, without adding in building an async runtime!
|
||||
However, we will note how async and await might be applicable to some of the
|
||||
same problems we will see in this chapter. Ultimately, as we noted back in
|
||||
Chapter 17, many async runtimes use thread pools for managing their work.</p>
|
||||
<p>We’ll therefore write the basic HTTP server and thread pool manually so that
|
||||
you can learn the general ideas and techniques behind the crates you might use
|
||||
in the future.</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user