[Python-Dev] the new 2.3a1 settimeout() with httplib and SSL

Ben Laurie ben@algroup.co.uk
Tue, 28 Jan 2003 10:28:21 +0000


Guido van Rossum wrote:
>>>>It doesn't look terribly hard to make the SSL wrapper obey 
>>>>the timeout, by
>>>>calling select() on the "raw" socket before calling 
>>>>SSL_write or SSL_read.
>>>>I'm willing to try to get this to work.
>>>
>>>That's cool.  I don't know much about the SSL_read() API -- does it
>>>promise to read exactly the requested number of byte (unless the
>>>socket is closed)?  Then a single select() before it is called may not
>>>be sufficient.
>>
>>I don't know any more than you do -- I've never looked at the OpenSSL docs
>>until today.  It looks like SSL_read may indeed return fewer bytes than
>>requested: http://www.openssl.org/docs/ssl/SSL_read.html
> 
> 
> Hm, from that page it looks like the internal implementation may
> actually repeatedly read from the socket, until it has processed a
> full 16K block.  But I may be mistaken, since it also refers to a
> non-blocking underlying "BIO", whatever that is. :-(

BIO is OpenSSL's I/O abstraction - if you have a nonblocking one, then 
SSL_read() will return when a read returns nothing, and if you want 
SSL_read() to not block, then you pretty much have to use a non-blocking 
BIO (because even if select() says there's data, there may not be enough 
to actually return any via SSL_read()).

I can help out here if there's still a problem.

Cheers,

Ben.

-- 
http://www.apache-ssl.org/ben.html       http://www.thebunker.net/

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff