Buffer size when receiving data through a socket?
gagsl-py2 at yahoo.com.ar
Wed Jun 18 09:02:04 CEST 2008
En Tue, 17 Jun 2008 14:32:44 -0300, John Salerno <johnjsal at nospamgmail.com> escribió:
> "Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> wrote in message
> news:mailman.547.1213684963.1044.python-list at python.org...
>> Note that most of the time you want to use the sendall() method, because
>> send() doesn't guarantee that all the data was actually sent.
> If I use sendall(), am I still recv'ing data with a given buffer size? What
> if I send more data than the buffer size. Is my code as written not prepared
> to handle that case? It seems like I might need to continue receiving data
> until there is no more to receive (in a loop?)...is that right?
send and recv are separate calls (they occur usually in different processes, even in different computers). Buffer sizes are separate too. It is posible to send 5K at once from one side, and require three recv calls on the other side to read it completely. On the other hand, if you try to read from a blocking socket (the default state) when no data is available, the read call will block (and the whole program freezes) until some data is received. There are several alternatives to avoid this, and surely they're explained in detail in a later chapter in your book...
More information about the Python-list