当前位置:网站首页>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 .
边栏推荐
- 如何使用clipboard.js库实现复制剪切功能
- 沙龙预告|GameFi 领域的瓶颈和解决方案
- scrapy爬虫mysql,Django等
- # Arthas 简单使用说明
- PostgreSQL reports an error when creating a trigger,
- C# Socke 服务器,客户端,UDP
- JS reverse tutorial second issue - Ape anthropology first question
- How to use Mongo shake to realize bidirectional synchronization of mongodb in shake database?
- 如何成为一名高级数字 IC 设计工程师(5-2)理论篇:ULP 低功耗设计技术精讲(上)
- 【无标题】
猜你喜欢

AI从感知走向智能认知

Elaborate on MySQL mvcc multi version control

The configuration and options of save actions are explained in detail, and you won't be confused after reading it

Lecture 1: stack containing min function

Use 3 in data modeling σ Eliminate outliers for data cleaning

如何使用clipboard.js库实现复制剪切功能

How does mongodb realize the creation and deletion of databases, the creation of deletion tables, and the addition, deletion, modification and query of data

# Arthas 简单使用说明

Arthas simple instructions

【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
随机推荐
JS judge whether checkbox is selected in the project
12、 Sort
剑指 Offer II 107. 矩阵中的距离
【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
sql 里面使用中文字符判断有问题,哪位遇到过?比如value&lt;&gt;`无`
[4g/5g/6g topic foundation-146]: Interpretation of white paper on 6G overall vision and potential key technologies-1-overall vision
How to use Mongo shake to realize bidirectional synchronization of mongodb in shake database?
scrapy爬虫mysql,Django等
JS逆向教程第一发
Dynamics 365online applicationuser creation method change
基础篇:带你从头到尾玩转注解
ViewPager2和VIewPager的區別以及ViewPager2實現輪播圖
Pick up the premise idea of programming
CDZSC_2022寒假个人训练赛21级(1)
Unity shader (learn more about vertex fragment shaders)
The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
Kubernetes cluster capacity expansion to add node nodes
JS inheritance prototype
How will fashion brands enter the meta universe?