Hopefully you are doing add_ssl_algorithms(..) (and a helpful
SSL_load_error_strings(..)) in the beginning. Also, did you try
ERR_print_errors_fp(stdout) and see if something appears? I may be restating
the obvious here.
The usual way I detect errors is to do a SSL_get_error(..) and do a
switch-case on all possible values.
Arun.
----- Original Message -----
From: Miha Wang <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 06, 2000 4:15 PM
Subject: Using SSL_accept with non blocking socket
>
> Hi, all -
>
> I am trying to write both sever/client that using non blocking socket.
> I am not using BIO based read/write. Here is what my code look like - The
> code is almost
> same as the serv.cpp and cli.cpp under demos/ssl, except I am seting non
> blocking
> option (O_NONBLOCK)
>
> SERVER:
> ========
> SSL *ssl;
> SSL_CTX *ctx;
>
> listen_sd = socket(..)
> flag = fcntl(listen_sd, F_GETFL);
> fcntl(listen_sd, F_SETFL, flag | O_NONBLOCK);
> bind(listen_sd, ...);
> listen(listen_sd,...);
> select(listen_sd+1, ...);
>
> sd = accept(listen_sd, ...);
>
> flag = fcntl(sd, F_GETFL);
> fcnt(sd, F_SETFL, flag | O_NONBLOCK);
>
> ctx = SSL_CTX_new(...);
> ssl = SSL_new(ctx);
> SSL_set_fd(ssl, sd);
> SSL_accept(ssl);
>
> for (;;) {
> SSL_read(ssl);
> SSL_write(ssl);
> }
>
> CLIENT:
> ======
>
> sd = socket(...);
> flag = fcntl(sd, F_GETFL);
> fcnt(sd, F_SETFL, flag | O_NONBLOCK);
>
> connect(sd,...);
>
> ctx = SSL_CTX_new(...);
> ssl = SSL_new(ctx);
> SSL_set_fd(ssl, sd);
> SSL_connect(ssl);
>
> SSL_write(ssl);
> SSL_read(ssl);
>
> The problem is that SSL_accept() failed (return -1). I could not get error
> code witn ERR_print_errors and I
> don't know why. Does anyone know what's wrong with this piece of code or
if
> it makes sense? The reason
> I am not using BIO is that I would like to manage both non-SSL and SSL
> connection over the socket.
> Can I do something like that? Any help is appreciated.
>
> Miha
>
> ______________________________________________________________________
> OpenSSL Project http://www.openssl.org
> User Support Mailing List [EMAIL PROTECTED]
> Automated List Manager [EMAIL PROTECTED]
>
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]