当前位置:网站首页>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 .
边栏推荐
- 第一讲:鸡蛋的硬度
- 第十四次试验
- 20排位赛3
- Install pyqt5 and Matplotlib module
- Netease Cloud Wechat applet
- [4G/5G/6G专题基础-146]: 6G总体愿景与潜在关键技术白皮书解读-1-总体愿景
- Niuke - Huawei question bank (61~70)
- Lecture 1: stack containing min function
- Information Security Experiment 1: implementation of DES encryption algorithm
- Arthas simple instructions
猜你喜欢
【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
VSCode+mingw64+cmake
Unity shader (basic concept)
flex弹性布局
Network request process
Information Security Experiment 2: using x-scanner scanning tool
基础篇:带你从头到尾玩转注解
Dynamics 365Online ApplicationUser创建方式变更
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
软件建模与分析
随机推荐
La différence entre viewpager 2 et viewpager et la mise en œuvre de la rotation viewpager 2
面试被问到了解哪些开发模型?看这一篇就够了
Kubernetes cluster capacity expansion to add node nodes
JS逆向教程第一发
Lecture 1: stack containing min function
How to become a senior digital IC Design Engineer (5-3) theory: ULP low power design technology (Part 2)
CodeForces - 1324D Pair of Topics(二分或双指针)
如何使用clipboard.js库实现复制剪切功能
JS inheritance prototype
flex弹性布局
網易雲微信小程序
Nested (multi-level) childrn routes, query parameters, named routes, replace attribute, props configuration of routes, params parameters of routes
CDZSC_2022寒假个人训练赛21级(2)
HCIP 第一天 笔记整理
The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart
JMeter JDBC batch references data as input parameters (the simplest method for the whole website)
ViewPager2和VIewPager的区别以及ViewPager2实现轮播图
Arthas simple instructions
**Grafana installation**
How does mongodb realize the creation and deletion of databases, the creation of deletion tables, and the addition, deletion, modification and query of data