Talk about send and recv methods
- First enter the bottom of the socket module
- Look up the parent class _socket source code, find the send method and recv method
- It shouldn’t be difficult to understand the source code above, just look at it briefly. Next, let’s talk about these two methods.
Next, let’s analyze first: the working principle of send and recv
Description:
- If send wants to send data, it must send data through the network card. The application program cannot directly send data through the network card. It needs to call the operating system interface, that is, the application program writes the sent data to the send buffer (memory The operating system controls the network card to send the data in the sending buffer to the server network card.
- Recv cannot directly receive data in the network card, that is: application software cannot directly receive data through the network card, it needs to call the operating system interface, the operating system receives the data through the network card, and writes the received data into the receiving buffer (memory The application program then obtains the data sent by the client from the receiving buffer area.
Summary: Neither recv nor send directly receives the other party’s data and sends data to the other party. The sent data will be written to the send buffer, and the received data is read from the receive buffer. The send data and receive data are ultimately The operating system controls the network card to complete
Disclaimer: This blog is only shared as a personal opinion. If you like it, please follow, bookmark, like and forward it in time. It is a blessing if the big world can meet! ! !