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 message exchange flow of RPC?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Most people do not understand the knowledge points of this article "how the message interaction process of RPC is", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "how the message interaction process of RPC is".

The above figure is a macro diagram of the information system interaction model, while the message interaction of RPC goes deep into the underlying layer.

RPC is a direct message interaction between two subsystems. It uses the socket provided by the operating system as the carrier of the message and defines the message content and boundaries in a specific message format.

The client of RPC accesses the send (send buffer) and receive (recv buffer) caches assigned to the current socket by the network module in the operating system kernel through the read and write API (read & write) of the file descriptor.

As shown in the figure above, the client process on the left writes RPC instruction messages to the send cache of the kernel, which transfers the data in the send cache to the physical hardware NIC, the network interface chip (Network Interface Circuit). NIC is responsible for transmitting the translated analog signal to the NIC of the server hardware through the network hardware. The NIC of the server converts the analog signal into byte data and stores it in the receiving cache allocated by the kernel for the socket. Finally, the server process reads the data from the receiving cache, which is the RPC instruction message transmitted by the source client process.

Messages flow from the user process to the physical hardware, and from the physical hardware to the user process, passing through a series of routing gateway nodes.

The figure above shows only the first half of a message exchange in RPC, and the second half is a reverse process of returning response data from the server process to the client process. The complete RPC process is shown in the following figure:

The above process is described in Python code below.

The Server end listens to the local port 8080 in a dead loop, waiting for the client to connect.

When the client starts, it connects to local port 8080, sends the word a string hello, and then waits for the server to respond.

After receiving the client connection, the server immediately receives the string sent by the client, that is, hello, and prints it out. Then immediately reply to the other party with a string world.

The client receives the world sent by the server and prints it out immediately.

Close the connection. Over.

If we look at the above code, it is very difficult to see the complex process shown in the figure above. In most people's minds, it is often the following simple model picture. By contrast, it is much simpler, which is the charm of operating system design, so that you can use it all the time without feeling its existence.

The above is the content of this article about "what is the message exchange process of RPC". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

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