Reputation: 164
http.createServer(onRequest).listen(8888);
http.createServer(onRequest).listen(8080);
In this case, I understand that two different http servers are created which listen to at different ports.
http.createServer(onRequestA).listen(8888);
http.createServer(onRequestB).listen(8080);
In this case the servers listen on various ports and also do different actions.
I have a a few questions.
Upvotes: 1
Views: 1575
Reputation: 9923
In answering your questions directly,
- Are these two approaches commonly used in the real world?
- Is there really an advantage of snippet 1?
- If such multiple servers can be created, what is the maximum number of servers that can be created from a single node instance?
Upvotes: 2