On Mon, 31 Jan 2000, Amir Amit wrote:

> hi.
> 
> when I run SSL_read on a socket (as the client), where the server is
> down, SSL_read returns with 0 - as there where no bytes to read from
> socket. This is not true - the server is down and there will never be
> something to read from server. Because the SSL_read command is non
> blocking and is in a loop until the buffer is read - the resault is
> endless loop.
> 
> Can anyone suggest a methood to check whether the SSL_read returns 0
> because there is nothing to read or because socket is broken?
> 
> Tring to write into the socket would do (the 'regular' write returns
> with signal SIGPIPE and return value of EPIPE) - but I don't want to
> write into the socket. What can I do?

If a select statement indicates the socket is readable, but a subsequent
read operation on the socket returns zero bytes, this indicates the socket
has been closed. I don't know if that's the "pure" way but it works. The
other thing to check; "man getsockopt", the option you might be interested
in is "SO_ERROR" (see "man 7 socket").

However, whether this maps to SSL_read or not I can't say ... it certainly
works for reads on the socket itself. (Eg. your problem might be that some
data *is* actually read from the socket by the SSL but was an incomplete
packet - so no decrypted data can be read out of the SSL until more data
arrives on the socket). Have you looked through apps/s_client.c and the
associated s_***.[ch] files?

Regards,
Geoff


----------------------------------------------------------------------
Geoff Thorpe                                    Email: [EMAIL PROTECTED]
Cryptographic Software Engineer, C2Net Europe    http://www.int.c2.net
----------------------------------------------------------------------

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to