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
As 2017 is coming to an end, many companies are p...
Qualcomm, Telstra, Ericsson and NETGEAR recently ...
Author: Yang Ailin, Intel Engineer (Cloud Orchest...
Enterprises are in the stage of high enthusiasm f...
Recently, cyberattacks on home wireless routers h...
[[312964]] 5G is the hottest word in the communic...
On December 10, 2021, the "2021 (11th) Telec...
[[182609]] The first 560Tb/s ultra-large capacity...
Hello everyone, I am amazing. Today, I will lead ...
On April 7, the Ruijie Networks 2023 National Par...
Nearly 800 million of these LTE subscriptions wer...
The three major operators have already commercial...
The Ministry of Industry and Information Technolo...
In addition to the rapid development and wide cov...
Before formally learning MPLS, let us review the ...