当前位置:网站首页>UDP communication
UDP communication
2022-08-05 10:59:00 【51CTO】

InetAddress类
IP是网络中存在一个数据,那么Java针对这类特殊的数据,会使用对应的类进行描述、封装.
学习Java中的网络编程,对应的类和接口都在java.net包下:
Java中使用InetAddress类描述封装IP对象.只要在程序中我们需要操作ip地址,只能通过InetAddress对象进行完成.
InetAddress类中没有构造方法,只能通过其中的静态的方法获取到InetAddress对象.

UDP通信
DatagramSocket对象介绍
UDP协议是面向无连接的协议,发送数据的一方尽管发送数据,它不关心接收方是否在接收数据.
在Java中使用DatagramSocket对象表示基于UDP协议的发送端或者是接收端.
数据报套接字是包投递服务的发送或接收点.每个在数据报套接字上发送或接收的包都是单独编址和路由的.从一台机器发送到另一台机器的多个包可能选择不同的路由,也可能按不同的顺序到达.
DatagramPacket对象介绍
数据报包用来实现无连接包投递服务.每条报文仅根据该包中包含的信息从一台机器路由到另一台机器.从一台机器发送到另一台机器的多个包可能选择不同的路由,也可能按不同的顺序到达.不对包投递做出保证.
DatagramPacket:它本身负责的对基于UDP协议发送或者接收的数据进行打包或者拆包的.
如何区分DatagramPacket对象到底是打包还是拆包的对象:完全依赖创建DatagramPacket对象时调用的构造方法.
代码实现案例


更多了解
边栏推荐
- Nature:猪死亡1小时后,器官再次运转
- OpenHarmony如何查询设备类型
- 012_SSS_ Improving Diffusion Model Efficiency Through Patching
- flutter 服务器返回数据判断是否为空
- 脱光衣服待着就能减肥,当真有这好事?
- CenOS MySQL入门及安装
- Discover the joy of C language
- Opencv图像缩放和平移
- Custom filters and interceptors implement ThreadLocal thread closure
- The query that the user's test score is greater than the average score of a single subject
猜你喜欢

机器学习——集成学习

CenOS MySQL入门及安装

朴素贝叶斯

上位机开发C#语言:模拟STC串口助手接收单片机发送数据

什么是 DevOps?看这一篇就够了!

How to choose coins and determine the corresponding strategy research

Integration testing of software testing

硅谷来信:快速行动,Facebook、Quora等成功的“神器”!

FPGA: Use of the development environment Vivado

TiDB 6.0 Placement Rules In SQL Usage Practice
随机推荐
Android development with Kotlin programming language - basic data types
MMDetection in action: MMDetection training and testing
5G NR system messages
解决2022Visual Studio中scanf返回值被忽略问题
金融业“限薪令”出台/ 软银出售过半阿里持仓/ DeepMind新实验室成立... 今日更多新鲜事在此...
How OpenHarmony Query Device Type
nyoj754 黑心医生 结构体优先队列
2022 Hangzhou Electric Power Multi-School Session 6 1008.Shinobu Loves Segment Tree Regular Questions
Header file search rules when compiling with GCC
停电。。。烦烦烦!!!
PCB布局必知必会:教你正确地布设运算放大器的电路板
FPGA: Use of the development environment Vivado
MySQL 中 auto_increment 自动插入主键值
Http-Sumggling缓存漏洞分析
How to choose coins and determine the corresponding strategy research
Chapter 5: Multithreaded Communication—wait and notify
Chapter 4: activiti RuntimeService settings get and get process variables, and the difference from taskService, set process variables when starting and completing tasks [easy to understand]
脱光衣服待着就能减肥,当真有这好事?
What are the standards for electrical engineering
PCB layout must know: teach you to correctly lay out the circuit board of the op amp