BIO_socket_wait, BIO_wait, BIO_connect_retry - BIO socket utility functions
#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 milliseconds);
int BIO_connect_retry(BIO *bio, long timeout);
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 bio, which is typically socket-based, for reading if bio is supposed to read, else for writing. It succeeds immediately if max_time == 0 (which means no timeout given). If sockets are not available it succeeds after waiting at most given milliseconds in order to help avoiding a tight busy loop at the caller.
BIO_connect_retry() connects via the given bio, retrying BIO_do_connect() until success or a timeout or error condition is reached. If the timeout parameter is > 0 this indicates the maximum number of seconds to wait until the connection is established. A value of 0 enables waiting indefinitely, while a value < 0 immediately leads to a timeout condition.
BIO_socket_wait(), BIO_wait(), and BIO_connect_retry() return -1 on error, 0 on timeout, and 1 on success.
BIO_socket_wait(), BIO_wait(), and BIO_connect_retry() were added in OpenSSL 3.0.
Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.