UDP UDP is a connectionless protocol, so the integrity of data cannot be guaranteed during transmission. JDK provides a network communication package, and provides two classes DatagramPacket and DatagramSocket under the java.net package to implement UDP communication. These two classes can be understood as follows: DatagramSocket is a road, and DatagramPacket is a car with people on it. In other words, DatagramSocket determines the communication target, and DatagramPacket represents the encapsulated data. The characteristics of UDP determine the application scenarios of the UDP protocol. The most common application scenario around me is the communication between IoT devices and servers. UDPClient Implementation
UDPServer Implementation
TCP TCP is a connection-oriented service. It establishes a connection through a three-way handshake and communicates by transmitting byte streams. Therefore, the integrity of the message can be guaranteed. Similarly, the java.net package also provides two packages, Socket and ServerSocket, to implement TCP communication. TCPClient
TCPServer
This article is reprinted from the WeChat public account "Java Journey", which can be followed through the following QR code. To reprint this article, please contact the Java Journey public account. |
<<: Gartner: Global 5G network infrastructure spending will nearly double in 2020
>>: The latest data on 5G construction is released: huge potential and promising future
1. Definition of fast charging [[343166]] There i...
Hengchuang Technology has released a promotion pl...
5G is currently the most eye-catching new technol...
Making the right choices in terms of data center ...
【51CTO.com Quick Translation】Before 2008, the ent...
HostUS has a low presence now, but it was very po...
HostingViet also launched a Double 11 event. From...
When the Internet began to be widely used in the ...
F5 Networks recently announced that the company h...
Compared with cloud computing, edge computing foc...
At this early stage, 6G wide-area wireless has fe...
According to Light Reading, executives of US tele...
We won’t talk about HTTP and HTTPS first. Let’s s...
Beijing, China, June 13, 2019 - VIAVI Solutions (...
[51CTO.com original article] From June 7 to 8, 20...