Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between net.connect and net.createConnection in node.js?

I was reading the documentation from the net module in Node.js and I can't see any difference between the methods net.connect and net.createConnection.

Are they exactly the same or is there is some difference?

like image 779
Valentin Barral Avatar asked Sep 09 '16 09:09

Valentin Barral


People also ask

What is the Connect module in node js used for?

Connect's extensions are mainly there to make it easy to plug in middleware. That's why Connect describes itself as a "middleware framework," and is often analogized to Ruby's Rack. Express does to Connect what Connect does to the http module: It offers a createServer method that extends Connect's Server prototype.

What kind of server does the net module's createServer method create?

createServer() may create a Unix domain socket and server.

What is server listen in node JS?

The server. listen() is an inbuilt application programming interface of class Socket within tls module which is used to start the server to listen the encrypted connection. Parameters: This method takes the following argument as parameter: port: It is the port number.

Which of the following API creates a client in node JS?

The Node. js Client uses the MarkLogic REST Client API to communicate with MarkLogic Server, so it uses the same security model.


Video Answer


1 Answers

There's no difference. Here's an extract from the source code:

exports.connect = exports.createConnection = function() {

I agree the documentation isn't clear on that point.

like image 121
Denys Séguret Avatar answered Sep 27 '22 20:09

Denys Séguret