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