1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1 christos BIO_socket_wait, 6 1.1 christos BIO_wait, 7 1.1 christos BIO_do_connect_retry 8 1.1 christos - BIO connection utility functions 9 1.1 christos 10 1.1 christos =head1 SYNOPSIS 11 1.1 christos 12 1.1 christos #include <openssl/bio.h> 13 1.1 christos 14 1.1 christos #ifndef OPENSSL_NO_SOCK 15 1.1 christos int BIO_socket_wait(int fd, int for_read, time_t max_time); 16 1.1 christos #endif 17 1.1 christos int BIO_wait(BIO *bio, time_t max_time, unsigned int nap_milliseconds); 18 1.1 christos int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds); 19 1.1 christos 20 1.1 christos =head1 DESCRIPTION 21 1.1 christos 22 1.1 christos BIO_socket_wait() waits on the socket B<fd> for reading if B<for_read> is not 0, 23 1.1 christos else for writing, at most until B<max_time>. 24 1.1 christos It succeeds immediately if B<max_time> == 0 (which means no timeout given). 25 1.1 christos 26 1.1 christos BIO_wait() waits at most until B<max_time> on the given (typically socket-based) 27 1.1 christos B<bio>, for reading if B<bio> is supposed to read, else for writing. 28 1.1 christos It is used by BIO_do_connect_retry() and can be used together L<BIO_read(3)>. 29 1.1 christos It succeeds immediately if B<max_time> == 0 (which means no timeout given). 30 1.1 christos If sockets are not available it supports polling by succeeding after sleeping 31 1.1 christos at most the given B<nap_milliseconds> in order to avoid a tight busy loop. 32 1.1 christos Via B<nap_milliseconds> the caller determines the polling granularity. 33 1.1 christos 34 1.1 christos BIO_do_connect_retry() connects via the given B<bio>. 35 1.1 christos It retries BIO_do_connect() as far as needed to reach a definite outcome, 36 1.1 christos i.e., connection succeeded, timeout has been reached, or an error occurred. 37 1.1 christos For nonblocking and potentially even non-socket BIOs it polls 38 1.1 christos every B<nap_milliseconds> and sleeps in between using BIO_wait(). 39 1.1 christos If B<nap_milliseconds> is < 0 then a default value of 100 ms is used. 40 1.1 christos If the B<timeout> parameter is > 0 this indicates the maximum number of seconds 41 1.1 christos to wait until the connection is established or a definite error occurred. 42 1.1 christos A value of 0 enables waiting indefinitely (i.e, no timeout), 43 1.1 christos while a value < 0 means that BIO_do_connect() is tried only once. 44 1.1 christos The function may, directly or indirectly, invoke ERR_clear_error(). 45 1.1 christos 46 1.1 christos =head1 RETURN VALUES 47 1.1 christos 48 1.1 christos BIO_socket_wait(), BIO_wait(), and BIO_do_connect_retry() 49 1.1 christos return -1 on error, 0 on timeout, and 1 on success. 50 1.1 christos 51 1.1 christos =head1 SEE ALSO 52 1.1 christos 53 1.1 christos L<BIO_do_connect(3)>, L<BIO_read(3)> 54 1.1 christos 55 1.1 christos =head1 HISTORY 56 1.1 christos 57 1.1 christos BIO_socket_wait(), BIO_wait(), and BIO_do_connect_retry() 58 1.1 christos were added in OpenSSL 3.0. 59 1.1 christos 60 1.1 christos =head1 COPYRIGHT 61 1.1 christos 62 1.1 christos Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved. 63 1.1 christos 64 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 65 1.1 christos this file except in compliance with the License. You can obtain a copy 66 1.1 christos in the file LICENSE in the source distribution or at 67 1.1 christos L<https://www.openssl.org/source/license.html>. 68 1.1 christos 69 1.1 christos =cut 70