Answer the question
In order to leave comments, you need to log in
What happens when nodejs server starts?
Here please explain what happens when I run (node server.js). Why is index.html launched when .js is launched, how does the server find where the main html lies. What is a server in relation to a browser, a js file to which requests are received, or some kind of program that sends requests to .js and the response back?! I would like some kind of chewed answer to everything.
Answer the question
In order to leave comments, you need to log in
There should be a code in server.js that will launch a socket on a port and listen for a connection, the browser connects and writes to the socket, blah blah, I need such and such a file, it comes to server.js and it does something in response to this.
The node does not have its own server, it's just a wrap around a c++ program and this applies to most of the modules built into it, through js you roughly communicate with them - you send commands and get answers.
You will find a chewed answer if you google on the topic of the tcp protocol and the http protocol.
Open the source code of the server.js file and read it - everything is written in detail there. Read the definitions of unknown functions in the manual or their source code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question