当前位置:网站首页>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 .
边栏推荐
- csdn涨薪技术-浅学Jmeter的几个常用的逻辑控制器使用
- 根据热门面试题分析Android事件分发机制(二)---事件冲突分析处理
- sql 里面使用中文字符判断有问题,哪位遇到过?比如value&lt;&gt;`无`
- nlohmann json
- Windows starts redis service
- 小程序弹出半角遮罩层
- 如何成为一名高级数字 IC 设计工程师(5-3)理论篇:ULP 低功耗设计技术精讲(下)
- Difference between process and thread
- JS inheritance prototype
- Dynamics 365Online ApplicationUser创建方式变更
猜你喜欢

Nested (multi-level) childrn routes, query parameters, named routes, replace attribute, props configuration of routes, params parameters of routes

面试被问到了解哪些开发模型?看这一篇就够了

基础篇:带你从头到尾玩转注解

Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management

【BW16 应用篇】安信可BW16模组/开发板AT指令实现MQTT通讯

【原创】程序员团队管理的核心是什么?

Unity shader (basic concept)

MongoDB怎么实现创建删除数据库、创建删除表、数据增删改查

Strategic cooperation subquery becomes the secret weapon of Octopus web browser

What development models did you know during the interview? Just read this one
随机推荐
Mysql:select ... for update
Detailed explanation of diffusion model
如何使用clipboard.js库实现复制剪切功能
Elaborate on MySQL mvcc multi version control
Impression notes finally support the default markdown preview mode
第一讲:包含min函数的栈
Communication mode between processes
CSDN salary increase technology - learn about the use of several common logic controllers of JMeter
The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart
C# Socke 服务器,客户端,UDP
Difference between process and thread
The industrial chain of consumer Internet is actually very short. It only undertakes the role of docking and matchmaking between upstream and downstream platforms
What development models did you know during the interview? Just read this one
消费互联网的产业链其实是很短的,它仅仅承接平台上下游的对接和撮合的角色
2020CCPC威海 J - Steins;Game (sg函数、线性基)
使用BigDecimal的坑
数据库多表关联查询问题
esp8266使用TF卡并读写数据(基于arduino)
sql 里面使用中文字符判断有问题,哪位遇到过?比如value&lt;&gt;`无`
CDZSC_2022寒假个人训练赛21级(1)