No, 'blocking' refers to the behavior of the underlying socket. If you have it set to nonblocking mode, you have to handle the case where it won't write due to a temporary condition.
If errno is EAGAIN, that means that the write or read *would* block. This can be handled in your initial case by checking for SSL_ERROR_SYSCALL and checking to see if errno is EAGAIN. If that's the case, you might as well yield to the next one, though not necessarily with a full error return -- the next time you call select(), you'll see that it has pending activity again. (In this case, replace your 'return(-1);' with 'continue;'.) -Kyle H 2009/3/30 Nikos Balkanas <nbalka...@gmail.com>: > Hi, > > Thanx for the quick response. Unfortunately the same problem persists: > > void conn_init_ssl(void) > { > SSL_library_init(); > SSL_load_error_strings(); > global_ssl_context = SSL_CTX_new(SSLv23_client_method()); > SSL_CTX_set_mode(global_ssl_context,. > SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER > | SSL_MODE_AUTO_RETRY); > } > > Any ideas? What should the underlying socket be blocking/not blocking? Can I > have at the same time non-blocking read and blocking write? > > BR, > Nikos > > ----- Original Message ----- From: "Kyle Hamilton" <aerow...@gmail.com> > To: <openssl-users@openssl.org> > Sent: Tuesday, March 31, 2009 3:13 AM > Subject: Re: SSL_write problem > > >> SSL_CTX_set_mode(ssl, SSL_MODE_AUTO_RETRY); >> >> 2009/3/30 Nikos Balkanas <nbalka...@gmail.com>: >>> >>> Hi, >>> >>> I would like to ideally use non-blocking SSL_read and blocking SSL_write. >>> Is >>> this possible with BIO_set_nbio? What should the underlying socket be in >>> that case? >>> >>> If this is not possible, as I suspect, i have the problem that the >>> non-blocking SSL_write with select, will stallΒ afterΒ first SSL_error of >>> SSL_ERROR_WANT_READ || SSL_ERROR_WANT_WRITE without ever writing the >>> data: >>> >>> while(((select(fd + 1, NULL, &rset, NULL, &alarm)) > 0) && FD_ISSET(fd, >>> &rset)) >>> { >>> Β Β Β Β Β res = SSL_write(ssl, input, len); >>> Β Β Β Β Β if (res == -1) >>> Β Β Β Β Β { >>> Β Β Β Β Β Β Β Β Β Β Β Β Β Β SSL_error = SSL_get_error(ssl, res); >>> Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β printf("SSL_error = %d\n", SSL_error); >>> Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β if (SSL_error != SSL_ERROR_WANT_READ && >>> SSL_error != >>> SSL_ERROR_WANT_WRITE) >>> Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β return(-1); >>> Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β else FD_CLR(fd, &rset); >>> Β Β Β Β Β Β } >>> Β Β Β Β Β Β else return(res); >>> } >>> >>> My only solution so far has been to use the non-blocking SSL_write as a >>> blocking one, but it is terribly inefficient, looping as many as 50 >>> timesΒ before writing the data: >>> >>> while((ret = SSL_write(ssl, request->data, request->len)) < 0) >>> { >>> Β Β Β Β Β Β Β SSL_error = SSL_get_error(ssl, ret); >>> Β Β Β Β Β Β Β Β if (SSL_error != SSL_ERROR_WANT_READ && SSL_error != >>> SSL_ERROR_WANT_WRITE) >>> Β Β Β Β Β Β Β Β Β Β Β Β Β Β break; >>> Β Β Β Β Β Β Β Β thr_yield(); >>> } >>> >>> Any ideas? >>> TIA, Nikos >>> >>> >> :I®r¶Γ¥² ¦1 ¥²z¥²€Άy² ®Ά z– > > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List openssl-us...@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