Opens the connection for a given socket.
Opens the connection for a given socket.
the port number
the host name or IP
a promise of an outcome
Opens the connection for a given socket.
Opens the connection for a given socket.
the port number
a promise of an outcome
Opens the connection for a given socket.
Opens the connection for a given socket.
the connection path
a promise of an outcome
Emitted once the socket is fully closed.
Emitted once the socket is fully closed. The argument had_error is a boolean which says if the socket was closed due to a transmission error.
- had_error <Boolean> true if the socket had a transmission error.
socket.on("close", function(had_error) { ... })
Emitted when a socket connection is successfully established.
Emitted when a socket connection is successfully established. See connect().
the callback
socket.on("connect", function() { ... })
Emitted when data is received.
Emitted when data is received. The argument data will be a Buffer or String. Encoding of data is set by socket.setEncoding(). (See the Readable Stream section for more information.)
Note that the data will be lost if there is no listener when a Socket emits a 'data' event.
- <Buffer>
socket.on("data", function(buffer) { ... })
Emitted when the write buffer becomes empty.
Emitted when the write buffer becomes empty. Can be used to throttle uploads.
See also: the return values of socket.write()
the callback
socket.on("drain", function(???) { ... })
Emitted when the other end of the socket sends a FIN packet.
Emitted when the other end of the socket sends a FIN packet.
By default (allowHalfOpen == false) the socket will destroy its file descriptor once it has written out its pending write queue. However, by setting allowHalfOpen == true the socket will not automatically end() its side allowing the user to write arbitrary amounts of data, with the caveat that the user is required to end() their side now.
the callback
socket.on("end", function(???) { ... })
Emitted after resolving the hostname but before connecting.
Emitted after resolving the hostname but before connecting. Not applicable to UNIX sockets.
the callback, with the following arguments:
socket.on("lookup", function(err, address, family, host) { ... })
Emitted if the socket times out from inactivity.
Emitted if the socket times out from inactivity. This is only to notify that the socket has been idle. The user must manually close the connection.
See also: socket.setTimeout()
the callback
socket.on("timeout", function(???) { ... })
the given socket
net.Socket Extensions