Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the architecture of TCP's CBG S?

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Many beginners are not very clear about what TCP's Cpact S architecture is like. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

TCP's C _ Band S architecture

The server first starts a net.Listen (). From the name, the net.Listen () seems to start a listener. In fact, this is because of the earliest design of socket socket. When designing the Goe language, it still follows the idea of Unix's original design and directly takes the name of the function. Students who are beginners of this function will have a misunderstanding that it is monitoring, but in fact it is not. This listen () function is not a real listening client, what do you want to listen to?

I want to monitor the connection between the client and me, but this Listen is not listening to the client, but I set the resources (IP, port) that the server is listening to. Accept () is the real monitoring. The implication, monitoring, I am waiting for you to visit me. That is to say, should you have been waiting before you visited me? let's write the program later. Whether to wait for Listen () or Accept, so Accept means to accept. When it is called by Accpet, it waits for the client to establish a connection with me. For example, it is already said in the diagram that it will block waiting for the user to establish a connection. The implication is that it has been blocking and waiting there before I have a user to establish a connection. In fact, the monitoring was initiated at Accept. Of course, Accept is not without source. It is necessary for Listen to set the connection method (tcp or udp), IP address and port before blocking to listen. When a client and server initiate a request, I call the Accept () function to complete, which means that the connection between my server and client has been established.

Carry out data transmission

What are you going to do next? For data transmission, the purpose for me to establish a connection is for data transmission. We assume here that this is generally the case. The client actively seeks the server to establish a connection, and when the connection is established, the client first sends data to the server. The server passively accepts the request from the client, passively accepts the client request data, and after receiving the request, the server carries on the corresponding analysis and processing. After processing, write back the data you want to request. The server Read () reads the request sent by the client, and Write () means that I will write back to you after I have processed your request. When all this is done, it means that a communication between us and the client is completed, then we can close the connection. Of course, if you want to continue to communicate later, the close () shutdown will be delayed.

The client process is very simple, because the server has to stand up and wait for the client to establish a connection with me, so the server has to be started first, and the client has to wait for your server to start and you are ready. I am sending you an access request, and the client sends an access request, which is also a function called net.Dail () function. This Dail () function sends a request to the blocked Accept (). If the server is ready, when Accept () returns, Dail also returns, let's say that the client has established a connection with the server, and the client sends data first, so the client first writes.

After sending the data, the server reads the client request for processing, writes back after processing, and then Read () reads the data written by the server. After reading, the client can also do simple processing. For example, after I read it, I print and display, write and read, and once the communication with the network end is completed, the client can close the connection. This is the general process.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report