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
In project practice, we have spent a lot of money...
[[325080]] May 7 report: Foreign media said that ...
ProfitServer sent an email about Christmas promot...
GigsGigsCloud has launched a new VPS in the Los A...
This month, spinservers is offering a flash sale ...
[[402402]] I believe most web developers are fami...
5G networks are the next generation of wireless t...
October 10, 2018 Shanghai - Huawei and Standard C...
DiyVM is a long-established Chinese hosting compa...
1. Write at the beginning Hello everyone, I'm...
iONcloud has released a special offer for the Yea...
JuHost has newly launched a data center in Tokyo,...
What is a Network Hub? A hub in a computer networ...
SK Telecom, Korea Telecom and LG Uplus have teame...
The world is generally moving from wired to wirel...