The first chapter website basics Chapter 2 common protocols and standards

Chapter 2 common protocols and standards

2.1 DNS protocol

  A DNS protocol is to resolve domain names to IP. In Windows you can use the nslookup command to view the DNS resolution result, such as using nslookup command to view the recorded Taobao analytical results shown in FIG.

  Direct access to the DNS server is called the local DNS server itself is no correspondence between domain names and IP, and then it will get saved to the cache from the primary DNS server when requesting, next time have the same domain name requests directly from cache get on it.

2.2 TCP / IP protocol and Socket

  IP is used to find address corresponding to the internetworking layer , TCP transport protocol is used to standardize the rules, corresponding to the transport layer . IP addresses are only responsible to find work specific to the transport of TCP to complete.

  Three-way handshake, waving four (? To be understood, follow-up will add a blog article on this knowledge point)

  In addition to the transport layer protocol for TCP as well as UDP , their main difference is that TCP connections, UDP is not connected , that is only the TCP protocol data transmission after good communication, and UDP protocol is to get straight to pass the address, the result is the TCP protocol transmission data thus generated is more reliable, faster and UDP transport. TCP is like a call, you need to dial other numbers to communicate, while UDP is like using a walkie-talkie, you can get up and speak directly. Typically video transmission, voice transmission, the integrity of the less demanding requirements of high speed transmission and large amount of data communication using the UDP more, and e-mail, web pages typically use the TCP protocol.

  TCP / IP protocol is just a set of rules, and not the specific work, just like in the program interface, Socket is a concrete manifestation of TCP / IP protocol.

 

2.3 HTTP protocol

  HTTP protocol is an application layer protocol, it is necessary to parse the HTTP protocol may be used only after the TCP / IP protocol of the received data. As in the past, like the telegram, telegraph equivalent Socket, responsible for selecting the target and send the contents of their past, but sent directly past data "Didi tick" and can not be used directly, but also need to be decoded (before sending need to re-transmit coded) before use, telegram encoding and decoding is equivalent to the network transmission of the HTTP protocol .

  HTTP protocol packet can be divided into a request message (request message) and a response packet (response message) of two types, both types consists of three parts: the first line, the head and the body . The first row request packet is a request row, including a method (Request Type), URL and HTTP version three elements, the first line is a response to the request status line, including HTTP version, status codes and a reason phrase three elements, the reason may be there can be no. Head to save some of the key attributes of a colon ":" segmentation. Specific content body storage, the request message stored in the main POST types of parameters , in response to the results stored in the page message to be displayed . The first line, the head and the body and the head of the content by the carriage-return linefeed (\ r \ n) division, a further plurality blank line between the head and the body, i.e. there are two consecutive CRLF . Their structure shown in FIG.

The method of the request packet means a GET, HEAD, POST, PUT, DELETE and other types, in a state response message code in the Status Response is, total can be divided into five categories:
  □ 1XX: informational status codes.
  □ 2XX: success status code, such as 200 indicates success.
  □ 3XX: Redirection status code, such as 301 to redirect the traffic.
  □ 4XX: Client Error status code, such as the 404 did not find the requested resource.
  □ 5XX: server error status code, such as 500 represents an internal error.

Message information can be viewed by firebug firefox plugin, for example, the message depends www.csdn.net requested URL:

After the header information is formatted, you can click in order to view the original "raw head" to view:

2.4 Servlet and Java Web Development

  J2EE Servlet is a standard part of a Java Web development standards. Standard and more significant than the mandatory agreement, but their role is basically the same, are used to develop uniform rules, because Java is a specific language, so in order to achieve unity it can set their own standards.

  After the adoption of the front of the TCP / IP protocol, HTTP protocol already available data, the role of the Servlet data is received and processed to generate the results back to the client, it's like the telegram received telegrams and also translated into plain text We need someone to make decisions and respond to the same content. ( Found by IP address, and then use the TCP protocol to transmit the contents of a file, the file content was analyzed by the HTTP protocol, the server is input to the logic processing Servlet do, and feeds back to the client. )

  Developed in Java Servlet standard processing Web requests, in order to use Servlet need to have appropriate Servlet container for the job, for example, it is a common Tomcat Servlet container.

 

Guess you like

Origin www.cnblogs.com/nachdenken/p/11255934.html