Network (J2SE learning essay Five)

Source: Internet
Author: User
Internet

1, IP is the English internet Protocol (network interconnection between the agreement) abbreviation, Chinese Jane is called "Network Association", namely for the computer network interconnection for communication and design of the agreement. (Network layer)

2, TCP is a connection-oriented communication protocol, TCP provides reliable and error-free data transmission between two computers. (Transport Layer)

3, UDP is connectionless communication protocol, UDP does not guarantee the transmission of reliable data, but can send data to several targets, receive data from several sources. (Transport Layer)

4, socket is the network driver layer provided to the application programming interface and a mechanism. The socket is created in the application, establishes a relationship with the driver through the binding mechanism, and tells itself the corresponding IP and port. The data that the application sends to the socket is then sent to the driver by the socket to the network. After the computer receives data related to the ip+port of the socket from the network, the application can extract the received data from the socket by giving it to the socket by the driver. The network is this way through the socket to send and receive data.

5, Java, respectively, for UDP and TCP two kinds of communication protocols provide the corresponding programming classes, These classes are stored in the java.net package, corresponding to UDP datagramsocket, and TCP ServerSocket (for server-side) and sockets (for clients).

6, Tcp-socket Model:

7, Udp-socket Programming Method:

A, through the Datagrampacket class object to wrap the data, including IP, Port, data.

B, by Datagramsocket class objects to send Datagrampacket class objects,

Datagramsocket.send (Datagrampacket p);

C, by Datagramsocket class objects to receive Datagrampacket class objects,

Datagramsocket.receive (Datagrampacket p);

D, according to the need for the Datagrampacket class object data processing.

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.