The net.Server Object
You use the net.Server
object to create a TCP socket server and begin listening for connections to which you will be able to read and write data. The Server
object is created internally when you call net.createServer()
. This object is intended to represent the socket server and handles listening for connections and then sending and receiving data on those connections to the server.
When the server receives a connection, the server creates a Socket
object and passes it to any connection event handlers that are listening. Because the Socket
object implements a Duplex
stream, you can use it with the write()
method to stream writes of data back to the client and a data
event handler to stream data from the client.
To create ...
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.