The HTTP Server Object
The Node.js HTTP Server
object provides the fundamental framework to implement HTTP servers. It provides an underlying socket that listens on a port and handles receiving requests and then sending responses out to client connections. While the server is listening, the Node.js application does not end.
The Server
object implements EventEmitter
and emits the events listed in Table 7.8. As you implement an HTTP server, you need to handle at least some or all of these events. For example, at a minimum, you need an event handler to handle the request
event that is triggered when a client request is received.
Get Node.js, MongoDB, and AngularJS Web Development 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.