Socket objects are created on both the socket server and the socket client and allow data to be written and read back and forth between them. The
Socket object implements the
Duplex stream, so it provides all the functionality that
Readable streams provide. For example, you can use the
write() method to stream writes of data to the server or client and a
data event handler to stream data from the server or client.
On the socket client, the
Socket object is created internally when you call
net.createConnection(). This object is intended to represent the socket connection to the server. You use the
Socket object to monitor the connection, send data to the server, and handle the response from the ...