I have read this from Socket Programming HOWTO in Python Documentation
you can transform your client socket into a file-like beast and use read and write. ... except to warn you that you need to use flush on sockets. These are buffered “files”, and a common mistake is to write something, and then read for a reply. Without a flush in there, you may wait forever for the reply, because the request may still be in your output buffer.
Now we come to the major stumbling block of sockets - send and recv operate on the network buffers
socket object in Python is a file descriptor, and you can use makefile() to get a file object associated with the socket.
According to the warning,
you need to use flush on sockets. These are buffered “files”...Without a flush in there, you may wait forever for the reply, because the request may still be in your output buffer...send and recv operate on the network buffers
I think when socket send/recv, there are actually two buffers: "file buffer" and "network buffer". If you transform socket to file like object and use write(data), first, data is written into "file output buffer", then into "network send buffer" by using flush. All this can explain the warning in the documentation: use flush after write or the read may block forever.
I drew a picture to show my opinion about underlying "two buffers" for socket.
So my question is how to understand the quote above? Is my "two buffers" model to understand right? Hope your reply, thank you!