logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

BIO_socket_wait, BIO_wait, BIO_do_connect_retry - BIO connection utility functions

Description

BIO_socket_wait() waits on the socket fd for reading if for_read is not 0, else for writing, at most
       until max_time.  It succeeds immediately if max_time == 0 (which means no timeout given).

       BIO_wait() waits at most until max_time on the given (typically socket-based) bio, for reading if bio is
       supposed to read, else for writing.  It is used by BIO_do_connect_retry() and can be used together
       BIO_read(3).  It succeeds immediately if max_time == 0 (which means no timeout given).  If sockets are
       not available it supports polling by succeeding after sleeping at most the given nap_milliseconds in
       order to avoid a tight busy loop.  Via nap_milliseconds the caller determines the polling granularity.

       BIO_do_connect_retry() connects via the given bio.  It retries BIO_do_connect() as far as needed to reach
       a definite outcome, i.e., connection succeeded, timeout has been reached, or an error occurred.  For
       nonblocking and potentially even non-socket BIOs it polls every nap_milliseconds and sleeps in between
       using BIO_wait().  If nap_milliseconds is < 0 then a default value of 100 ms is used.  If the timeout
       parameter is > 0 this indicates the maximum number of seconds to wait until the connection is established
       or a definite error occurred.  A value of 0 enables waiting indefinitely (i.e, no timeout), while a value
       < 0 means that BIO_do_connect() is tried only once.  The function may, directly or indirectly, invoke
       ERR_clear_error().

History

BIO_socket_wait(), BIO_wait(), and BIO_do_connect_retry() were added in OpenSSL 3.0.

Name

       BIO_socket_wait, BIO_wait, BIO_do_connect_retry - BIO connection utility functions

Return Values

BIO_socket_wait(), BIO_wait(), and BIO_do_connect_retry() return -1 on error, 0 on timeout, and 1 on
       success.

See Also

BIO_do_connect(3), BIO_read(3)

Synopsis

        #include <openssl/bio.h>

        #ifndef OPENSSL_NO_SOCK
        int BIO_socket_wait(int fd, int for_read, time_t max_time);
        #endif
        int BIO_wait(BIO *bio, time_t max_time, unsigned int nap_milliseconds);
        int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds);

See Also