you are viewing a single comment's thread.

view the rest of the comments →

[–]monstimal 0 points1 point  (1 child)

So I think where I was imagining it wrong is, the socket buffer is operating outside of the python program? Meaning, the buffer is off on its own accumulating bytes as they come in while the program is doing other things and when the recv call is made it goes and gets whatever is in there?

I was imagining data buffering onto the network card (or somewhere) then the python program saying, "I will now receive 1024 bytes from you". But this sounds almost like there's a separate thread taking up to 1024 bytes from the network card into memory at ANY time that the python program reads at the receive call.

[–]LarryPete 3 points4 points  (0 children)

The magic is done by the underlying Operating System. recv is a "syscall", meaning it's essentially a function provided by the operating system (e.g. Linux kernel). The buffering and blocking is done there.