Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I will try to answer that:</p> <p><strong>Q1:</strong></p> <p>createServer basically creates a process which listens on the specified port for the requests. So yes you can call it as a virtual server which constantly listens for request at the port.</p> <p><strong>Q2:</strong></p> <p>Yes you can say that it has now 2 servers</p> <p>For eg: you server had apache initially which listens to port 80 (you can access it as <a href="http://example.com/" rel="nofollow">http://example.com/</a> it by default looks for port 80)</p> <p>and then you also start the node service listening on some other port for eg: port 8456 (you can access it as <a href="http://example.com:8456/" rel="nofollow">http://example.com:8456/</a> which will look for port 8456)</p> <p>So yes you can there are two servers.</p> <p><strong>EDIT</strong></p> <p><strong>Q</strong>: So what would be the difference if the page is served by the physical server and the virtual server created by node.js?</p> <p>Physical Server and Node Server are 2 different things and there is no way a single request is going to both the servers.</p> <p>For eg: I use apache server to host my website running on PHP. It serves all the html contents of my website (which involves connecting to mysql for data). Some of the requests could be:</p> <ol> <li><a href="http://example.com/reports.php" rel="nofollow">http://example.com/reports.php</a> </li> <li><a href="http://example.com/search.php" rel="nofollow">http://example.com/search.php</a></li> </ol> <p>At the other end I might be using nodejs server for totally another purpose. For eg: I might use it for an API, which returns JSON/XML in return. I can use this API myself for some dynamic contents by making AJAX calls with javascript or simple CURL commands from PHP. Or I might also make this API available to public. Some of the requests could be:</p> <ol> <li><a href="http://example.com:8456/getList?apikey=" rel="nofollow">http://example.com:8456/getList?apikey=</a>&amp;param1=&amp;param2=</li> </ol> <p>My choice for NodeJs Server used as an API would be for its ability to handle concurrent request and since its asynchronous for file operations it will be much faster than PHP.</p> <p>In this case I have a website which is not only working on PHP but its the combination of 2 different technologies (PHP on Apache and Nodejs) and hence 2 servers are totally different running on same server but have there own execution space.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload