2020 New Java Interview Questions-Network

王林
Release: 2020-06-19 17:22:32
forward
2290 people have browsed it

2020 New Java Interview Questions-Network

#1. What do http response codes 301 and 302 represent? What's the difference?

Answer: 301 and 302 are both HTTP status codes, and both represent that a certain URL has been transferred.

Difference:

301 redirect: 301 represents Permanently Moved.

302 redirect: 302 represents Temporarily Moved.

(Recommended tutorial: java introductory program)

2. What is the difference between forward and redirect?

Forward and Redirect represent two request forwarding methods: direct forwarding and indirect forwarding.

Direct forwarding method (Forward), the client and browser only issue one request. Servlet, HTML, JSP or other information resources, the second information resource responds to the request, and saves it in the request object request. The objects are shared with each information resource.

The indirect forwarding method (Redirect) is actually two HTTP requests. When the server responds to the first request, it allows the browser to send a request to another URL to achieve the purpose of forwarding.

To give a popular example:

Direct forwarding is equivalent to: "A asked B to borrow money, B said he didn't have it, B went to C to borrow it, and if he couldn't borrow it, he would pass the message on. To A";

Indirect forwarding is equivalent to: "A asked B to borrow money, but B said he didn't have it, so he asked A to borrow money from C."

(Related video tutorial recommendations: java video tutorial)

3. Briefly describe the difference between tcp and udp?

TCP is connection-oriented (such as making a phone call, you must first dial to establish a connection); UDP is connectionless, that is, there is no need to establish a connection before sending data.

TCP provides reliable services. That is to say, the data transmitted through the TCP connection is error-free, not lost, not repeated, and arrives in order; UDP uses its best efforts to deliver, that is, reliable delivery is not guaranteed.

Tcp achieves reliable transmission through checksums, retransmission control, sequence number identification, sliding windows, and confirmation responses. For example, retransmission control when packets are lost can also be used to control the order of packets that are out of order.

UDP has better real-time performance and higher working efficiency than TCP. It is suitable for communications or broadcast communications that require high-speed transmission and real-time performance.

Each TCP connection can only be point-to-point; UDP supports one-to-one, one-to-many, many-to-one and many-to-many interactive communication.

TCP requires more system resources, while UDP requires less system resources.

4. Why does tcp need to shake hands three times, but not two times? Why?

In order to achieve reliable data transmission, both parties communicating with the TCP protocol must maintain a sequence number to identify which of the data packets sent have been received by the other party. The three-way handshake process is a necessary step for both communicating parties to inform each other of the starting value of the sequence number and confirm that the other party has received the starting value of the sequence number.

If there are only two handshakes, at most only the starting sequence number of the connection initiator can be confirmed, and the sequence number selected by the other party cannot be confirmed.

5. Tell me how tcp sticky packets are generated?

(1) The sender generates sticky packets

Clients and servers that use the TCP protocol to transmit data often maintain a long connection state (data is sent once per connection and there is no sticky packets), both parties can continue to transmit data as long as the connection is not disconnected; but when the data packets sent are too small, the TCP protocol will enable the Nagle algorithm by default to merge and send these smaller data packets (buffer Data sending is a stacking process); this merging process is carried out in the sending buffer, which means that when the data is sent it is already in a sticky state.

2020 New Java Interview Questions-Network

(2) The receiver generates sticky packets

The process when the receiver uses the TCP protocol to receive data is as follows: the data goes to the receiver, from the network The lower part of the model is passed to the transport layer. The TCP protocol processing of the transport layer is to place it in the receiving buffer, and then the application layer actively obtains it (C language uses recv, read and other functions); at this time, a problem will arise, that is, we are The read data function called in the program cannot take out the data in the buffer in time, and the next data comes and part of it is put at the end of the buffer. When we read the data, it will be a sticky packet. (Speed ​​of putting data > Speed ​​of getting data at the application layer)

2020 New Java Interview Questions-Network

2020 New Java Interview Questions-Network

If you want to know more interview questions, you can visitjava interview questions.

The above is the detailed content of 2020 New Java Interview Questions-Network. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template