size of socket.recv buffer

Peter Hansen peter at engcorp.com
Tue Feb 26 00:21:19 EST 2002


Locke wrote:
> 
> so you are saying it sends the data in groups? how do i know how many calls
> to recv i need to do before the server is done sending everything it needs
> to send? because if i call recv after the server is done sending everything,
> the program will just deadlock waiting. any suggestions? anybody know
> anything about pop3?

You need a protocol between client and server with termination sequences
demarking the end of a block.  Things like POP3 (which you can readily find
lots of information on via google... try "POP3 RFC" or something like that)
use a command/response interaction with each part of the exchange terminated
with CR/LF.  Other protocols might use something different.  You could
try sending the length ahead of time and waiting only for the appropriate
amount of data (harder, perhaps more efficient or lower latency).

Also, if you are worried about "deadlock" (it's really just 'blocking') 
you can turn blocking off and put your client recv() in a loop with
a timeout or something... there are many ways of handling these things.
Looking at example code will teach you more.

-Peter



More information about the Python-list mailing list