当前位置:网站首页>Deep understanding of UDP, TCP
Deep understanding of UDP, TCP
2022-07-07 09:46:00 【Don't ask me y】
I have learned these two concepts several times
Every time, it seems that I don't understand
I listened to it several times today
I made a simple summary
If the description is not clear, please correct
1.UDP
A、UDP No client and server side , The connection must be initiated by the client , Because only the server port number and IP The address is fixed , Be sure to use IP Address and port number , namely bind() Method ; And use send() send data , When the other party receives data recvfrom() receive , When disconnecting, either party can disconnect , Because the server has recorded the client's IP Address and port number ;
B、UDP Is an unreliable connection protocol , Send a lot of , It is allowed to use UDP Protocol for transmission , Like audio , Video and other documents , The result of losing some data has no effect on the viewer .
2.TCP
)TCP It's connection-oriented , reliable , Byte transfer protocol .
A、 Connection oriented , There are clients and servers , When connecting for the first time , There must be three handshake agreements , When disconnected , It's a four wave agreement ;connect,read,write,close.
B、 Monitor the network status at all times , Use the sliding window to control the transmission of data packets , When the network state becomes worse , The number of transmitted bytes is the original 1/2, When the network state recovers , If the current data transmission volume > The original 1/2, The transmission speed will be doubled ; If the current data transmission volume < The original 1/2, Then every transmission , Add a byte .
Simple communication based on client and server :
Server side :
client :
Output results :
principle :
The client determines the service port number , establish socket service , Define a socke, For reception accept Method returns a message from the server , use bufferedreader , use getinputstream Method to input information from the client , use printwriter,getoutputstream Method to send a message from the server to the client . take pw For message system.out.println Write output stream ,flush Method to the client , The client with bufferedreader,getinputstream Method reception . Close input stream , Close output stream , Close socket .
边栏推荐
- 使用BigDecimal的坑
- Lesson 1: hardness of eggs
- **grafana安装**
- The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart
- How to become a senior digital IC Design Engineer (5-3) theory: ULP low power design technology (Part 2)
- CDZSC_2022寒假个人训练赛21级(2)
- 创建一个长度为6的int型数组,要求数组元素的值都在1-30之间,且是随机赋值。同时,要求元素的值各不相同。
- How to speed up video playback in browser
- Unity shader (pass user data to shader)
- nlohmann json
猜你喜欢
Netease Cloud Wechat applet
小程序弹出半角遮罩层
Impression notes finally support the default markdown preview mode
Lecture 1: stack containing min function
[4G/5G/6G专题基础-146]: 6G总体愿景与潜在关键技术白皮书解读-1-总体愿景
How will fashion brands enter the meta universe?
Binary tree high frequency question type
Oracle installation enhancements error
Esp8266 uses TF card and reads and writes data (based on Arduino)
Vs2013 generate solutions super slow solutions
随机推荐
章鱼未来之星获得25万美金奖励|章鱼加速器2022夏季创业营圆满落幕
Strategic cooperation subquery becomes the secret weapon of Octopus web browser
js逆向教程第二发-猿人学第一题
The industrial chain of consumer Internet is actually very short. It only undertakes the role of docking and matchmaking between upstream and downstream platforms
Create an int type array with a length of 6. The values of the array elements are required to be between 1-30 and are assigned randomly. At the same time, the values of the required elements are diffe
高斯消元
小程序弹出半角遮罩层
Scratch crawler mysql, Django, etc
shake数据库中怎么使用Mongo-shake实现MongoDB的双向同步啊?
Addition, deletion, modification and query of ThinkPHP database
Binary tree high frequency question type
第一讲:包含min函数的栈
Database multi table Association query problem
细说Mysql MVCC多版本控制
flink. CDC sqlserver. 可以再次写入sqlserver中么 有连接器的 dem
Loxodonframework quick start
Oracle installation enhancements error
[4G/5G/6G专题基础-147]: 6G总体愿景与潜在关键技术白皮书解读-2-6G发展的宏观驱动力
Schema-validation: wrong column type encountered in column XXX in table XXX
flex弹性布局