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
Recently, the three major operators released thei...
Beijing, March 10, 2021 - Denodo, a leader in dat...
When it comes to TCP connection establishment and...
Corporate Owned Single-Use Units (COSUs) are used...
What is the difference between the upcoming IPv6 ...
On September 28, hackers used Facebook's secu...
4G, the mobile network that allows us to make cal...
At the 2017 Huawei Connect Conference held from S...
BandwagonHost has launched a special package, a d...
5G technology is the most anticipated network upd...
@baimmi China UnionPay Co., Ltd. Due to the confi...
Why is Software Lifecycle Management Critical to ...
In CAN-bus circuit design, the transceiver can th...
[51CTO.com original article] On a weekend in earl...
PacificRack released several special products thi...