BIO_socket_wait.3ossl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "BIO_SOCKET_WAIT 3ossl"
  58. .TH BIO_SOCKET_WAIT 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. BIO_socket_wait,
  65. BIO_wait,
  66. BIO_do_connect_retry
  67. \&\- BIO connection utility functions
  68. .SH SYNOPSIS
  69. .IX Header "SYNOPSIS"
  70. .Vb 1
  71. \& #include <openssl/bio.h>
  72. \&
  73. \& #ifndef OPENSSL_NO_SOCK
  74. \& int BIO_socket_wait(int fd, int for_read, time_t max_time);
  75. \& #endif
  76. \& int BIO_wait(BIO *bio, time_t max_time, unsigned int nap_milliseconds);
  77. \& int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds);
  78. .Ve
  79. .SH DESCRIPTION
  80. .IX Header "DESCRIPTION"
  81. \&\fBBIO_socket_wait()\fR waits on the socket \fBfd\fR for reading if \fBfor_read\fR is not 0,
  82. else for writing, at most until \fBmax_time\fR.
  83. It succeeds immediately if \fBmax_time\fR == 0 (which means no timeout given).
  84. .PP
  85. \&\fBBIO_wait()\fR waits at most until \fBmax_time\fR on the given (typically socket-based)
  86. \&\fBbio\fR, for reading if \fBbio\fR is supposed to read, else for writing.
  87. It is used by \fBBIO_do_connect_retry()\fR and can be used together \fBBIO_read\fR\|(3).
  88. It succeeds immediately if \fBmax_time\fR == 0 (which means no timeout given).
  89. If sockets are not available it supports polling by succeeding after sleeping
  90. at most the given \fBnap_milliseconds\fR in order to avoid a tight busy loop.
  91. Via \fBnap_milliseconds\fR the caller determines the polling granularity.
  92. .PP
  93. \&\fBBIO_do_connect_retry()\fR connects via the given \fBbio\fR.
  94. It retries \fBBIO_do_connect()\fR as far as needed to reach a definite outcome,
  95. i.e., connection succeeded, timeout has been reached, or an error occurred.
  96. For nonblocking and potentially even non-socket BIOs it polls
  97. every \fBnap_milliseconds\fR and sleeps in between using \fBBIO_wait()\fR.
  98. If \fBnap_milliseconds\fR is < 0 then a default value of 100 ms is used.
  99. If the \fBtimeout\fR parameter is > 0 this indicates the maximum number of seconds
  100. to wait until the connection is established or a definite error occurred.
  101. A value of 0 enables waiting indefinitely (i.e, no timeout),
  102. while a value < 0 means that \fBBIO_do_connect()\fR is tried only once.
  103. The function may, directly or indirectly, invoke \fBERR_clear_error()\fR.
  104. .SH "RETURN VALUES"
  105. .IX Header "RETURN VALUES"
  106. \&\fBBIO_socket_wait()\fR, \fBBIO_wait()\fR, and \fBBIO_do_connect_retry()\fR
  107. return \-1 on error, 0 on timeout, and 1 on success.
  108. .SH "SEE ALSO"
  109. .IX Header "SEE ALSO"
  110. \&\fBBIO_do_connect\fR\|(3), \fBBIO_read\fR\|(3)
  111. .SH HISTORY
  112. .IX Header "HISTORY"
  113. \&\fBBIO_socket_wait()\fR, \fBBIO_wait()\fR, and \fBBIO_do_connect_retry()\fR
  114. were added in OpenSSL 3.0.
  115. .SH COPYRIGHT
  116. .IX Header "COPYRIGHT"
  117. Copyright 2019\-2020 The OpenSSL Project Authors. All Rights Reserved.
  118. .PP
  119. Licensed under the Apache License 2.0 (the "License"). You may not use
  120. this file except in compliance with the License. You can obtain a copy
  121. in the file LICENSE in the source distribution or at
  122. <https://www.openssl.org/source/license.html>.