On Wed, Jul 07, 1999 at 10:24:22AM +0200, Juan Pablo Rojas Jimenez wrote:
> Bodo Moeller wrote:
>>> SSL_ERROR_WANT_WRITE
>>> SSL_ERROR_WANT_READ
>> These can happen only with non-blocking I/O (or with BIO pairs, which
>> will be available in OpenSSL 0.9.4). It means that the program has to
>> retry the SSL_... call; progress is guaranteed for the next call if
>> writing or reading, respectively, is possible on the underlying I/O
>> device by then (for sockets, typically select() or poll() will be
>> used to determine when time is ready for retry).
> Does it mean that when reveiving a SSL_ERROR_WANT_WRITE/READ
> the program hasn't sent/received all data it was expecting to... i mean ,
> the data i told him to send/receive , or it could be something that the
> library does internally ( or both )?
It means that some I/O operation that the SSL library needs to finish
to do what you asked it to did not complete: For socket I/O, this
means that EWOULDBLOCK occured. If you don't know what this means,
you'll have to read something on the socket API first before you can
expect to understand the OpenSSL behaviour.
>> It is important to keep in mind that all those SSL_... calls may
>> *both* read and write: E.g. you can observe SSL_ERROR_WANT_WRITE after
>> a SSL_read.
> So , what should we do then? retry de call with null parameters? , with
> original parameters.
As a general rule, use the original parameters again and again until
the call reports success (or a real error). Even when retrying,
SSL_write(...) needs access to the buffer that it is asked to write;
and SSL_read(...) needs storage for the data that it reads from the
SSL/TLS conneciton.
> I suppose SSL_read/write returns also the data written/read , so
> depending on this value , i'd have to do one thing or another , am I
> wrong?
The do return the number of bytes read or written, yes. SSL_get_error
returns SSL_ERROR_NONE if and only if that return value (which is
passed to SSL_get_error in its second argument) is positive;
so you can handle this with just one case statement.
> If I get a SSL_ERROR_WANT_WRITE after a SSL_read call ( or viceversa )
> i have to call SSL_write(ssl,NULL,0) ( for example )?
No, just repeat the SSL_read call (when you know that the socket is
ready for writing). The library remembers internally what it has to
do.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]