The TCP/UDP of 4.Java network programming

Source: Internet
Author: User

Common Transport protocols: UDP , TCP

UDP protocol:

Features:
1. Encapsulate the data and the source and destination into a packet, no need to establish a connection
2. Limit the size of each packet within 64K
3. Due to no connection, it is an unreliable agreement
4. No need to establish a connection, fast

For example, if you send a parcel to your home, it will be sent regardless of whether someone is at home at this time. when the courier is sent to your home, if someone, the family received the package, if no one at home at this time, the package (packet) was discarded.

Self-Understanding:

When we established the connection, you said: "Have you eaten?" "And then you don't care whether she hears it or not, you continue to say the second sentence:" How about playing table tennis in the afternoon? ”。 As there is no certainty that the other person hears what you have just said, there are four possible situations:

The first situation: she heard both words, and then replied: "After dinner, you can play together." ".

The second situation: she only heard the first sentence, so only replied: "Eaten!" "But will not answer whether you can play together."

The third situation: she only heard the second sentence, so only answer: "Can play together!" "But I won't answer if you have eaten."

Fourth situation: She didn't hear two words, so she won't answer any of your words.

This is the non-connected UDP protocol for the transport layer.

TCP protocol:

Characteristics:
1. Establish a connection to form a channel for transmitting data.
2. Make large data transfers in the connection.
3. Complete the connection via three handshakes, which is a reliable protocol.
4. Must establish a connection, the efficiency will be slightly lower

Classic examples:

1. Download the file.

2. Call.

Self-Understanding:

When we established the connection, you said: "Have you eaten?" And then you say nothing and wait for her answer. When she tells you she hears what you say, and answers you: "Eaten." "Then you start to say the second sentence:" How about playing table tennis in the afternoon? " then you say nothing and wait for her answer. When she tells you she hears what you say, and answers you: "Can play together!" "You tell her you heard her answer, and then the call terminates!"

This is the TCP protocol for the three-time handshake of the transmission plane to the connection.

TCP three-time handshake plot:

The TCP/UDP of 4.Java network programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.