Bin Lu
Wed, 10 Mar 2010 15:51:37 -0800
>> Hi,
>>
>> I have the following code snippet:
>>
>> bio = BIO_new_connect(host);
>> BIO_set_conn_port(bio, port);
>> BIO_set_nbio(bio, 1)
>> while (true) {
>> status = BIO_do_connect(bio);
>> if (status > 0 || !BIO_should_retry(bio)) {
>> break;
>> }
>> sleep(1);
>> }
>>
>> BIO_do_connect() always returns -1 the first time and 1 the 2nd time,
>> regardless if the server is reachable or not.
>>
>> If I use the blocking mode, then it returns 1 on reachable server and hangs
>> otherwise, which seems expected.
>>
>> Is there anything wrong in the above code, why it returns the same value for
>> reachable or non-reachable servers?
>>
>
>A call cannot immediately determine if a server is reachable. It typically has
>to wait until it gets >a reply from the remote server.
>
>That's why you get a retry: the TCP stack is waiting for a response. Only when
>it gets that response >can the connection continue or not as the case may be.
Thanks Steve. Why the connection is still invalid, because subsequent OCSP_sendreq_bio() receives no response(while in blocking mode it does), after the 2nd time call to BIO_do_connect() in the loop which always returns 1/success ? It is failing in OCSP connection after the 2nd successful BIO_do_connect() call as soon as the BIO is made non-blocking. It works fine in blocking mode but it does not timeout if the server is unreachable. Regards, -binlu >Steve. >-- >Dr Stephen N. Henson. OpenSSL project core developer. >Commercial tech support now available see: http://www.openssl.org >>______________________________________________________________________ >OpenSSL Project http://www.openssl.org >User Support Mailing List openssl-users@openssl.org >Automated List Manager majord...@openssl.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org