Java Network Programming (ii) two types of transport protocols: TCP UDP

Source: Internet
Author: User

Two types of transport protocols: TCP,UDPTCP

TCP is the short name of Transfer Control Protocol , which is a connection-oriented protocol that guarantees reliable transmission .

In the TCP/IP protocol,

IP layer is mainly responsible for the location of the network host, the routing of data transmission, by the IP address can uniquely determine a host on the Internet   .

  The TCP layer provides an application-oriented reliable or unreliable data transmission mechanism , which is the main object of network programming, and generally does not need to care about how the IP layer handles the data.

With the TCP protocol transmission, a sequential error-free data stream is obtained.

  A connection must be established between the sender and the receiver's paired two sockets in order to communicate on the basis of the TCP protocol.

When a socket (usually a server socket) waits for a connection, another socket can request a connection, and once the two sockets are connected, they can transmit two-way data and both can send or receive operations.

  TCP is a connection-based protocol that can provide reliable data flow between two computers.

This reliable communication channel is required for applications such as HTTP, FTP, and Telnet.

UDP

UDP is the abbreviation of User Datagram Protocol and is a non-connected protocol .

UDP is a protocol that sends a separate packet, called a datagram , from one computer to another, which does not guarantee that the datagram will reach its destination correctly, and that it is a non-connection-oriented protocol.

Each datagram is a separate message, including the full source address or destination address, which travels to the destination on the network with any possible path, so it is not guaranteed to arrive at the destination, the time of arrival, and the correctness of the content.

comparison of TCP and UDP

With UDP, the full address information is given in each datagram, so there is no need to establish a connection between the sender and the receiver .

For the TCP protocol, since it is a connection-oriented protocol, it is necessary to establish a connection before data transfer between sockets, so there is more time to establish a connection in TCP.

There is a size limit for transmitting data using UDP, and each transmitted datagram must be limited to 64KB .

TCP does not have this limitation, and once the connection is established, the sockets on both sides can transmit large amounts of data in a uniform format .

UDP is an unreliable protocol in which datagrams sent by the sender do not necessarily reach the receiver in the same order.

TCP is a reliable protocol that ensures that the receiver is getting all the data sent by the sender in full and proper order.

Reliable transmission is to pay a price, the correctness of the data content inspection will inevitably occupy the computer processing time and network bandwidth. Therefore , the efficiency of TCP transmission is not as high as UDP .

TCP has strong vitality in network communications, such as remote Connection (Telnet) and file Transfer (FTP), which require the data to be reliably transmitted over an indefinite length.

In contrast, UDP is easy to operate and requires less monitoring, so it is often used for client/server applications in decentralized systems with high LAN reliability.

  

Here is the recommended book "TCP/IP detailed", divided into three volumes.

TCP/IP model

The TCP/IP model consists of four levels:

Application Layer

Transport Layer

Network layer

Network interface

The correspondence between TCP/IP and the OSI Reference Model:

  

network classes in the JDK

Through the classes in the java.net package, Java programs can communicate over the Internet using TCP or UDP protocols.

Java supports TCP/IP by extending existing streaming input/output interfaces and increasing the creation of input/output object features on the network .

Java supports TCP and UDP protocol families.

TCP is used for reliable streaming input/output of the network.

UDP supports a simpler, faster, point-to-point datagram pattern.

Two types of transport protocols: TCP,UDPTCP

TCP is the short name of Transfer Control Protocol , which is a connection-oriented protocol that guarantees reliable transmission .

In the TCP/IP protocol,

IP layer is mainly responsible for the location of the network host, the routing of data transmission, by the IP address can uniquely determine a host on the Internet   .

  The TCP layer provides an application-oriented reliable or unreliable data transmission mechanism , which is the main object of network programming, and generally does not need to care about how the IP layer handles the data.

With the TCP protocol transmission, a sequential error-free data stream is obtained.

  A connection must be established between the sender and the receiver's paired two sockets in order to communicate on the basis of the TCP protocol.

When a socket (usually a server socket) waits for a connection, another socket can request a connection, and once the two sockets are connected, they can transmit two-way data and both can send or receive operations.

  TCP is a connection-based protocol that can provide reliable data flow between two computers.

This reliable communication channel is required for applications such as HTTP, FTP, and Telnet.

UDP

UDP is the abbreviation of User Datagram Protocol and is a non-connected protocol .

UDP is a protocol that sends a separate packet, called a datagram , from one computer to another, which does not guarantee that the datagram will reach its destination correctly, and that it is a non-connection-oriented protocol.

Each datagram is a separate message, including the full source address or destination address, which travels to the destination on the network with any possible path, so it is not guaranteed to arrive at the destination, the time of arrival, and the correctness of the content.

comparison of TCP and UDP

With UDP, the full address information is given in each datagram, so there is no need to establish a connection between the sender and the receiver .

For the TCP protocol, since it is a connection-oriented protocol, it is necessary to establish a connection before data transfer between sockets, so there is more time to establish a connection in TCP.

There is a size limit for transmitting data using UDP, and each transmitted datagram must be limited to 64KB .

TCP does not have this limitation, and once the connection is established, the sockets on both sides can transmit large amounts of data in a uniform format .

UDP is an unreliable protocol in which datagrams sent by the sender do not necessarily reach the receiver in the same order.

TCP is a reliable protocol that ensures that the receiver is getting all the data sent by the sender in full and proper order.

Reliable transmission is to pay a price, the correctness of the data content inspection will inevitably occupy the computer processing time and network bandwidth. Therefore , the efficiency of TCP transmission is not as high as UDP .

TCP has strong vitality in network communications, such as remote Connection (Telnet) and file Transfer (FTP), which require the data to be reliably transmitted over an indefinite length.

In contrast, UDP is easy to operate and requires less monitoring, so it is often used for client/server applications in decentralized systems with high LAN reliability.

  

Here is the recommended book "TCP/IP detailed", divided into three volumes.

TCP/IP model

The TCP/IP model consists of four levels:

Application Layer

Transport Layer

Network layer

Network interface

The correspondence between TCP/IP and the OSI Reference Model:

  

network classes in the JDK

Through the classes in the java.net package, Java programs can communicate over the Internet using TCP or UDP protocols.

Java supports TCP/IP by extending existing streaming input/output interfaces and increasing the creation of input/output object features on the network .

Java supports TCP and UDP protocol families.

TCP is used for reliable streaming input/output of the network.

UDP supports a simpler, faster, point-to-point datagram pattern.

Java Network Programming (ii) two types of transport protocols: TCP UDP

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.