The net.Socket Object
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 Writable
and 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.connect()
or 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 ...
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.