Listening for HTTP requests
In Chapter 4, I created a simple web server so that I could demonstrate the way that JavaScript code is executed. In doing so, I skipped over the details of how the code worked, but now it is time to go back and dig into the details.
The createServer
function in the http
module is used to create Server
objects that can be used to listen for and process HTTP requests. The Server
object requires configuration before it starts listening for requests and the most useful methods and properties defined by the Server
class are described in Table 5.3.
Table 5.3: Useful server methods and properties
Name |
Description |
|
This method starts listening for requests on a specified port. |
|
This method... |