Milan Křápek wrote:
>  Hi, 
>     I have problem. I am creating client application that send to server some 
> data via TCP or TLS protocol. For both the TCP and TLS I use the openssl 
> library. I am using unblocking BIO. And I have this problem with recognizing 
> if connection is aborted. 
> 
>     I am trying to read from bio each 5 seconds to recognize if the 
> connection is aborted. I try this example. I started my application and 
> connected to the server. Than I sent some data each way. While I was sending 
> I pull out the network cable. The expected result was that my application 
> recognizes that connction was interrupted and throws a connection error event.
>     My way to do this was, that after each sending or reading that return 
> some error value I called BIO_should_retry and if this method returned false 
> I take it as conection error. But under linux when I pull out the network 
> cable. Reading or writing returns error code as I was expecting but when I 
> call BIO_should_retry it says me that I should retry. 
>    Is there any other way to recognize if the connection is interrupted? Have 
> anybody had the same problem as me?
> 

The proper way to detect events on a non-blocking fd would be to do a
select() / poll() on it. It's seems that you;re not doing that.

In case you pull out the cable (disrupt connection in some way) during a
SSL read/write, it's quite possible that SSL gets a -1 from the syscall
and records the fact that it was in mid-read (hence should_retry). I
think it's plainly up to the application code to handle system level errors.


-jb
-- 
No snowflake in an avalanche ever feels responsible.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to