当前位置:网站首页>QT TCP UDP network communication < theory >
QT TCP UDP network communication < theory >
2022-06-25 12:37:00 【haoming Hu】
It takes about three or four blogs to talk about QT The content of network communication inside , Actually, it can't be said that QT Network communication , No matter what language , It's almost the same , The essence lies in the different ways of implementation , The mechanism of communication is the same
Chapter one : Basic knowledge of network communication
Network communication overview : Network programming is the foundation of the interconnection of all things , What's in use now TCP/IP agreement , It itself is divided into four layers : application layer 、 Transport layer 、 The layer 、 Network interface layer . But as an ordinary programmer , We only use the transport layer and application layer when we write the program . Now common network communication protocols mainly include :TCP UDP FTP HTTP, Whether in the window still Linux, The system provides a unified socket , That's what they say socket, stay QT in ,QT The network module has been encapsulated QtNetwor, The integration is very high , Basically meet the basic needs .
Transmission control protocol (transmission control protocol ,TCP) It's a reliable 、 Connection oriented 、 Transport protocols for data streams ,HTTP、FTP There are TCP Shadow ,TCP The protocol is suitable for continuous data transmission , It's also a transmission with guaranteed data security .
TCP working principle :TCP Protocol can provide reliable communication connection , So that the byte stream sent by my computer can be sent to other specified computers on the network without error , Its reliability is mainly due to its request ---- The reply This set of safe mechanism , It's not a simple request and response , It's a complex connection process , Here's the picture :
Three handshakes and four waves are more important , This mainly introduces the communication mechanism , About tcp Connect three handshakes and four waves, and add to other blogs next time .
Start the server first , Start the client after a while , It establishes a connection with this server after three handshakes . For some time after that , The client sends a request to the server , The server processes the request , And send back a response for the client . This process continues , Until the client sends a file terminator to the server , And close the client connection , Then the server also closes the connection on the server side , End running or wait for a new client connection .
Because of the complicated communication process , So the communication speed must be slower than UDP communication .
UDP:
User datagram protocol (User Data Protocol, UDP) It's a simple lightweight 、 unreliable 、 For datagram 、
Connectionless transport layer protocol , It can be used when reliability is not very important , Short message 、 Broadcast information, etc .
There are several situations suitable for application :
● Most of the network data is short message ;
● Have a large number of clients ;
● No special requirements for data security ;
● The burden of the Internet is very heavy , But it requires high response speed .
This is obvious , for instance :QQ And wechat are fully in line with the above applications .
working principle :UDP Client to UDP The server sends a certain length of request message , The limitation of message size is related to the protocol implementation of each system , But not beyond the lower level IP Under the agreement 64KB; UDP The server also responds in the form of a message . If the server does not receive this request , The client does not resend , So the transmission of message is unreliable .
Communication process :
The client doesn't have to connect to the server , Only responsible for sending message data to the server , Of course, the server does not need to manage whether the client is connected , Just listen to the client .
边栏推荐
- Penetration tool environment -- use of cknife Chinese kitchen knife
- MySQL and excel tables importing database data (Excel for MySQL)
- PHP appends the same elements to a two-dimensional array
- Swagger document generated by node project API in vscode
- Possible causes of wechat applet decryption failure
- Ramda rejects objects with null and empty object values in the data
- Jeecgboot startup popup configuration is still incorrect
- 19. Implementation of MVVM architecture based on WPF event to command
- R language uses GLM function to build Poisson logarithmic linear regression model, processes three-dimensional contingency table data to build saturation model, and poisgof function of epidisplay pack
- PHP files running online
猜你喜欢

Penetration tool environment -- use of cknife Chinese kitchen knife

A set of automated paperless office system (oa+ approval process) source code: with data dictionary

Uncover gaussdb (for redis): comprehensive comparison of CODIS

Swagger document generated by node project API in vscode

Zhangxiaobai's way of penetration (VIII) - detailed operation steps of SQL injection - Boolean blind injection of blind injection

High performance + million level Excel data import and export

A commonly used statistical modeling method -- difference analysis
![[oceanbase] Introduction to oceanbase and its comparison with MySQL](/img/1c/bd2bcddb7af4647407d2bc351f5f5d.png)
[oceanbase] Introduction to oceanbase and its comparison with MySQL

Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection

ECSHOP commodity wholesale multi attribute multi specification multi inventory batch purchase ECSHOP wholesale plug-in ECSHOP multi attribute order
随机推荐
Polling and long polling
Possible causes of wechat applet decryption failure
Explain factor analysis in simple terms, with case teaching (full)
Learning notes 2022 overview | automatic graph machine learning, describing AGML methods, libraries and directions
thinkphp3.2.5 GIF. class. php for php7.4
ECSHOP commodity page multi-attribute batch purchase plug-ins ECSHOP wholesale plug-ins multi-attribute order placing, multi-attribute batch purchase of commodities
【数据中台】数据中台的OneID是个什么鬼,主数据它不香吗?
15. Notes on the button style of WPF
R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the summary function to obtain the summary statistical information
Implementing Domain Driven Design - using the ABP framework - Summary of a series of articles
JQ dynamic setting radio does not take effect when selected
Yunfan mall -- Yunfan mall system development source code sharing
Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection
Install MySQL client
Zhangxiaobai's way of penetration (V) -- detailed explanation of upload vulnerability and parsing vulnerability
Total number of MySQL statistics, used and unused
Flutter common commands and problems
An example of using dynamic datalist
ARM V7 连续加载/存储
High imitation blue playing network disk file sharing to make money network disk PHP system source code