"Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Both programs say recv(buffer_size) - buffer_size is the maximum number of 
> bytes to be RECEIVED, that is, READ. recv will return at most buffer_size 
> bytes. It may return less than that, even if the other side sent the data 
> in a single operation.
> 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. 
> <http://docs.python.org/lib/socket-objects.html>

I was wondering about sendall(). The examples I've read in two different 
books are consistent in their use of send() and don't even mention 
sendall(), so I thought maybe it was for a more specialized situation.

> Yes, it is stored in an intermediate buffer until you read it. You typed 
> "hello" and sent it, the server replied with the string "You typed: 
> hello"; the OS stores it. You read only 10 bytes "You typed:", the 
> remaining are still in the buffer. Next round: you type something, the 
> server replies, you read the remaining bytes from the original reply, and 
> so on...

Oh!!!! I didn't even count "You typed:" as part of the 10 bytes! And what a 
coincidence that it happens to be exactly 10 characters! That really helped 
to hide the problem from me!

> (Note that in this particular configuration, the client will fill its 
> buffer at some time: because the server sends at least 11 bytes each 
> round, but the client reads at most 10 bytes, so the client is always 
> behind the server...)

How is the server sending back 11 bytes? Is it because it's sending at least 
the 10 characters, plus the extra space?

Thanks! 


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to