The following excerpt from Go Web programming is easy to understand.
When we browse the Web, we open the browser, enter the URL and press ENTER, then we will show you what you want to see. What is hidden behind this seemingly simple user behavior?
For the normal online process, the system is actually doing this: the browser itself is a client, when you enter the URL, the first browser will go to request a DNS server, through DNS to obtain the corresponding domain name corresponding IP, and then through the IP address to locate the IP corresponding server, the request to establish a TCP connection, After the browser sends the HTTP request (request) packet, the server receives the request packet before it starts processing the request package, and the server calls its own service, returning an HTTP Response (response) packet The client receives a response from the server and starts rendering the body (body) in the response package, and then disconnects the TCP connection to the server after receiving the entire content.
A Web server is also known as an HTTP server, which communicates with clients through the HTTP protocol. This client usually refers to a Web browser (in fact, the mobile client is also implemented inside the browser).
How the Web server works can simply be summed up as:
· The client establishes a TCP connection to the server through the TCP/IP protocol
· The client sends an HTTP protocol request packet to the server, requesting a resource document from the server
· The server sends an HTTP protocol reply packet to the client if the requested resource contains content that is in dynamic language.
Then the server invokes the dynamic language's interpretation engine to handle "dynamic content" and returns the processed data to the client
· The client and server are disconnected. The client interprets the HTML document and renders the graphic results on the client screen
A simple HTTP transaction is implemented in this way and looks complicated, and the principle is actually quite simple. It is important to note that the communication between the client and the server is non-persistent, that is, when the server sends an answer, it disconnects from the client and waits for the next request.
How does the Web work, browse the Web, open a browser, enter a URL, press ENTER, and then display the content, what is the process?