Dr. Stephen Henson wrote:
On Tue, Sep 04, 2007, Jim Marshall wrote:

Jim Fox wrote:
Doesn't need a faq. The man page says the purpose of the BIO_set_nbio_accept macro is to set blocking or non-blocking mode. Seems like that's what it will do.

Jim

On Sep 3, 2007, at 11:31 AM, Jim Marshall wrote:

Jim Marshall wrote:
I'm looking at using non-blocking I/O in some places in my code, and I have a question. The 'BIO_set_nbio_accept' says it will set the underlying socket to blocking/non-blocking mode, but all the examples and stuff I see say to use 'BIO_socket_ioctl(SSL_get_fd(ssl),FIONBIO,&sl)'. Can 'BIO_set_nbio_accept' be used to change the state of an SSL socket?
Thank you
Jim
Yes I know that, but all the examples I have seen do not use this macro. As an aside I tried using it this past weekend and it did not seem to work, the socket was not set to non-blocking mode as I expected.


That works on an accept BIO and sets the accept socket to non-blocking mode.

The macro BIO_set_nbio() sets BIOs to non-blocking mode in general. However
note that this only takes place during initialization so if you make the call
after the BIO has been used (e.g. connected or I/O performed) it wont work.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]


Thanks for the feedback, but the BIO_set_nbio still doesn't seem to work. Here is what I am doing. I have a function which creates the accept BIO and calls BIO_set_nbio as follows (this is obviously trimmed down from my actual function):

        BIO* ret = BIO_new_accept(hostString);
        if (ret != NULL)
        {
            BIO_set_nbio(ret, 1); // This returns 1??
            BIO_set_bind_mode(ret, BIO_BIND_REUSEADDR);
            /* bind & listen */
            if (BIO_do_accept(ret) > 0)
            {
                return ret;
            }
...

now in my elsewhere in the program I have a 'startlistening' function which does the following:

        acceptRet = BIO_do_accept(sock);
        if (acceptRet > 0)
        {
            BIO* client = NULL;
            SSL* ssl = NULL;
            client = BIO_pop(sock);
            ssl = SSL_new(gCtx);
...

I would expect that the BIO_do_accept would return immediately if there was no connections waiting. It does not.

Any thoughts on what I am doing wrong?

Thanks
Jim

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to