BIO_socket_wait.pod 2.5 KB

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