socket.rcv timeout while-loop

Stephen Hansen me+list/python at ixokai.io
Thu Feb 3 20:29:39 EST 2011


On 2/3/11 3:02 PM, Dwayne Blind wrote:
> Thanks Stephen. It's really nice of you.
> 
> I have not understood everything though. (I have never used a context
> manager before.)
> 
> Here are some comments :
> 
>      timeout = s.gettimeout()    # Is that the default timeout ?
>      s.settimeout(3) # I guess this is a 3 second timeout
>      s.recv(1024)
>      s.settimeout(timeout) # You change it back ?

Yes.

> So with a while loop, it should be :

I don't understand why you're doing this while loop business. Your
original question is asking for how to NOT do that, I thought. How to
use a timeout instead.

I showed you how to use a timeout instead-- now you're mixing it in with
what you originally had? Why?



-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20110203/e26293ad/attachment-0001.sig>


More information about the Python-list mailing list