On Mon, Mar 19, 2001 at 11:13:22PM -0700, Nathan Parker wrote:

> How can I poll the SSL layer to see if it has data I can read?  I want to 
> implement a function to read N bytes with a time limit, but using select() 
> messes me up -- it doesn't know if there is data available within SSL.

SSL_pending returns the number of bytes available for immediate
reading.  SSL_pending never does network I/O; it also will not look at
unencrypted data that may have been buffered elsewhere in the system.
Thus it probably does not solve your problem.

One possibility is to use non-blocking sockets and select() or poll().
It is true that select() does not know about SSL/TLS application data.
Instead of immediately calling select(), you should first
call SSL_read, then call SSL_get_error, and then (if necessary)
wait for the appropriate condition [*] before either retrying SSL_read
or giving up in case of a timeout.  You may have to iterate this,
so you should do some bookkeeping for the remaining time limit.

[*] See the SSL_get_error manual page,
    http://www.openssl.org/docs/ssl/SSL_get_error.html.
    You *must* read the manual page in order to handle non-blocking
    I/O correctly!



-- 
Bodo Möller <[EMAIL PROTECTED]>
PGP http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/moeller/0x36d2c658.html
* TU Darmstadt, Theoretische Informatik, Alexanderstr. 10, D-64283 Darmstadt
* Tel. +49-6151-16-6628, Fax +49-6151-16-6036
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to