Yes, the protocol is asynchronous exactly, not "query/response" sequence, and could not re-design it now.
I could not find sufficient documents or examples about non-blocking I/O for newbie like me. By way of experiment, I tried to re-write the code again with BIO and non-blocking I/O. The read() wrapping function I made newlly is below; ------- snip ------- BIO_set_nbio( cbio, 1 ) ; BIO_do_connect( cbio ) ; BIO_do_handshake( cbio ) ; int read_ssl( ... ) { while ( 1 ) { pthread_mutex_lock( &rw_lock ) ; int ret = BIO_read( cbio ... ) ; pthread_mutex_unlock( &rw_lock ) ; if ( ret > 0 ) { break ; } else if ( ! BIO_should_retry( cbio ) ) { do_something_ERROR() ; break ; } usleep( a_little ) ; // to prevent wasting CPU } } ------- snip ------- Will this work correctly with multithreaded asynchronous I/O? But I think, this way is not better than simple blocking I/O like the original code. It wastes CPU by the loop and gets poor response time by the sleep. Is there any way better than it? Can you please help me again? Thank you in advance! -- YAMANEKO / Mao http://yamamaya.com/ http://wiki.livedoor.jp/yamamaya_com/ ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]