当前位置:网站首页>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 .
边栏推荐
- Sqlplus garbled code problem, find the solution
- ViewPager2和VIewPager的区别以及ViewPager2实现轮播图
- [4g/5g/6g topic foundation -147]: Interpretation of the white paper on 6G's overall vision and potential key technologies -2-6g's macro driving force for development
- PostgreSQL reports an error when creating a trigger,
- 如何成为一名高级数字 IC 设计工程师(5-3)理论篇:ULP 低功耗设计技术精讲(下)
- sqlplus乱码问题,求解答
- How to use Mongo shake to realize bidirectional synchronization of mongodb in shake database?
- How to become a senior digital IC Design Engineer (1-6) Verilog coding Grammar: Classic Digital IC Design
- What development models did you know during the interview? Just read this one
- sql 里面使用中文字符判断有问题,哪位遇到过?比如value&lt;&gt;`无`
猜你喜欢
随机推荐
数据建模中利用3σ剔除异常值进行数据清洗
面试被问到了解哪些开发模型?看这一篇就够了
iNFTnews | 时尚品牌将以什么方式进入元宇宙?
sql 里面使用中文字符判断有问题,哪位遇到过?比如value&lt;&gt;`无`
The industrial chain of consumer Internet is actually very short. It only undertakes the role of docking and matchmaking between upstream and downstream platforms
PostgreSQL reports an error when creating a trigger,
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
**grafana安装**
Unity shader (data type in cghlsl)
Thinkphp3.2 information disclosure
牛客网——华为题库(61~70)
PLC信号处理系列之开关量信号防抖FB
CDZSC_2022寒假个人训练赛21级(1)
Difference between process and thread
csdn涨薪技术-浅学Jmeter的几个常用的逻辑控制器使用
shake数据库中怎么使用Mongo-shake实现MongoDB的双向同步啊?
大佬们,请问 MySQL-CDC 有什么办法将 upsert 消息转换为 append only 消
网易云微信小程序
如何成为一名高级数字 IC 设计工程师(1-6)Verilog 编码语法篇:经典数字 IC 设计
创建一个长度为6的int型数组,要求数组元素的值都在1-30之间,且是随机赋值。同时,要求元素的值各不相同。