This section estimates

It mainly involves the following points:

  1. The meaning of the potocol
  2. What is a URL? (WWW url = HTTP + + HTML)
  3. What is IP? Used to locate a device
  4. Router function? Bridge between Intranet and extranet
  5. What is a port?
  6. What is a domain name? IP’s nickname
  7. How do domain names correspond to IP addresses?

1. What does HTTP mean?

Hyper Text Transfer Protocol. One of the three things Sir Lee invented, the World Wide Web WWW=URL+HTTP+HTML

2. What is IP?

Internet Protocol. There are two main things:

  1. How to locate a device (computer, phone, router, etc.)
  2. How to encapsulate data packets to communicate with other devices.

As long as you are online, you should have at least one independent IP

3. How to obtain an external IP address and an internal IP address?

  1. Get a broadband connection
  2. Install a router
  3. The router gets an extranet IP, your address on the Internet, and that extranet IP even goes to your cell phone on the road
  4. Reboot the router, the external IP may change, the external IP is not fixed (about 5000 yuan per month, you can get a fixed external IP)
  5. The router creates an Intranet in your home. The devices on the Intranet use an Intranet IP address. Generally, the Intranet IP address is in the format of 192.168.xxx.xxx
  6. A router assigns an Intranet IP address to itself, usually 192.168.1.1. All devices connected to the router have a unique Intranet IP address, such as 192.168.1.2

4. Router functions

Route requests from the internal network to the external network and information from the external network to the internal network.

  1. The router has two IP addresses, one external IP (assigned by the network operator) and one internal IP (assigned by the router itself).
  2. Devices on the Intranet and extranet cannot directly access each other
  3. Devices on the Intranet can access each other, and so can the Internet
  4. A router, also known as a gateway, is the only channel connecting the internal and external networks

5. Several special IP addresses

  1. 127.0.0.1 indicates itself
  2. Localhost is specified as itself through hosts

If you have an index.html web page on your desktop, you can access it from either of the following addresses

127.0.0.1:8080 / index. HTML localhost: 8080 / index. HTMLCopy the code

3.0.0.0.0 does not represent any device and is generally not used in the front end

6. In addition to IP, also need port port (IP and port are indispensable)

IP used to locate a device, port used to locate a device service, with the IP and port, you can locate a device providing services, such as baidu server provides Chinese language search services A machine to provide different services, you need to use a different port number (analogy in the restaurant drinks window and food window) :

  1. HTTP service: port 80
  2. HTTPS service: port 443
  3. FTP service: port 21
  4. There are a total of 65535 ports

How do I know what port number to use? Port number = port number = port number

  1. Port 0-1023 for system use, not recommended for individual use
  2. Personal use 1024-63335, such as http-server using port 8080

7. The domain name

Domain name is an alternate name for IP. It is convenient to remember the IP address of Baidu by ping baidu.com

  1. One domain name can correspond to different IP addresses. Load balancing prevents the same IP address from receiving too many visits
  2. An IP address can correspond to an invalid domain name: Multiple companies share a server, saving costs

8.DNS: Sets up the query relationship between domain names and IP addresses

How do domain names correspond to IP addresses? When you use broadband, China Telecom/Unicom will provide you with a DNS server for free

  1. Enter a domain name, like “taobao.com”
  2. The browser asks the DNS server provided by China Telecom and China Unicom what is the IP address corresponding to “Taobao.com”
  3. Telecom/Unicom returns an IP and the browser retrieves it
  4. The browser sends a request to port 80/443 of this IP
  5. The purpose of the request is to view the home page of “Taobao.com”

9. Level of domain name

WWW prefixes are not generally used by programmers

  1. Com is a top-level domain name
  2. Baidu.com is the second level domain name (commonly known as the first level domain name)
  3. www.baidu.com is a level 3 domain name (commonly known as level 2 domain name)
  4. Unizhoulu.github. IO is a subdomain of github
  5. Github. IO Provides the subdomain name userid.github
  6. www.xxx.com and xxx.com may be different websites
  7. The WWW is redundant

10.URL (Uniform Resource Locator)

URL:Uniform Resource Locator

For example:www.baidu.com/s?wd=hello&…

  1. The HTTPS protocol
  2. The domain name www.baidu.com
  3. / s path
  4. Wd = hello&rsV _spt=1 Query parameters
  5. # 5 anchors
  6. HTTPS the default port is 443

How do I request different pages from the same server?

Request a different path

https://juejin.cn/pins
Copy the code
https://juejin.cn/topics
Copy the code

How to request different content on the same page?

Using query parameters

https://baidu.com/?wd=chinese
Copy the code
https://baidu.com/?wd=japan
Copy the code

How to view different contents on the same page with the same query parameter?

Using the anchor point

  1. Anchors do not support Chinese
  2. Anchor points are not visible in the Network panel
  3. Anchors are not passed to the server

11. The curl command

The curl command can send an HTTP request to curl -v http://baidu.com. 1. The url will be overwritten by the curl tool. The TCP connection is established. After the connection is successful, HTTP requests are sent

12. Request and response model

1. A server can be understood as a computer without a monitor, that is, a host. 2. The server can open multiple ports and have IP addresses. 3. Front-end engineer’s code usually runs on the client (mostly browser), and back-end engineer’s code usually runs on the server.

How does the client send the request?

Curl -v https://www.baidu.com Some concepts 1. User Agent: a tool that helps users send requests, such as Chrome or Curl