SSL_CTX_set_read_ahead.pod 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set_read_ahead, SSL_CTX_get_read_ahead,
  4. SSL_set_read_ahead, SSL_get_read_ahead,
  5. SSL_CTX_get_default_read_ahead
  6. - manage whether to read as many input bytes as possible
  7. =head1 SYNOPSIS
  8. #include <openssl/ssl.h>
  9. void SSL_set_read_ahead(SSL *s, int yes);
  10. int SSL_get_read_ahead(const SSL *s);
  11. SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes);
  12. long SSL_CTX_get_read_ahead(SSL_CTX *ctx);
  13. long SSL_CTX_get_default_read_ahead(SSL_CTX *ctx);
  14. =head1 DESCRIPTION
  15. SSL_CTX_set_read_ahead() and SSL_set_read_ahead() set whether we should read as
  16. many input bytes as possible (for non-blocking reads) or not. For example if
  17. B<x> bytes are currently required by OpenSSL, but B<y> bytes are available from
  18. the underlying BIO (where B<y> > B<x>), then OpenSSL will read all B<y> bytes
  19. into its buffer (providing that the buffer is large enough) if reading ahead is
  20. on, or B<x> bytes otherwise.
  21. Setting the parameter B<yes> to 0 turns reading ahead is off, other values turn
  22. it on.
  23. SSL_CTX_set_default_read_ahead() is identical to SSL_CTX_set_read_ahead().
  24. SSL_CTX_get_read_ahead() and SSL_get_read_ahead() indicate whether reading
  25. ahead has been set or not.
  26. SSL_CTX_get_default_read_ahead() is identical to SSL_CTX_get_read_ahead().
  27. =head1 NOTES
  28. These functions have no impact when used with DTLS. The return values for
  29. SSL_CTX_get_read_head() and SSL_get_read_ahead() are undefined for DTLS. Setting
  30. B<read_ahead> can impact the behaviour of the SSL_pending() function
  31. (see L<SSL_pending(3)>).
  32. Since SSL_read() can return B<SSL_ERROR_WANT_READ> for non-application data
  33. records, and SSL_has_pending() can't tell the difference between processed and
  34. unprocessed data, it's recommended that if read ahead is turned on that
  35. B<SSL_MODE_AUTO_RETRY> is not turned off using SSL_CTX_clear_mode().
  36. That will prevent getting B<SSL_ERROR_WANT_READ> when there is still a complete
  37. record availale that hasn't been processed.
  38. If the application wants to continue to use the underlying transport (e.g. TCP
  39. connection) after the SSL connection is finished using SSL_shutdown() reading
  40. ahead should be turned off.
  41. Otherwise the SSL structure might read data that it shouldn't.
  42. =head1 RETURN VALUES
  43. SSL_get_read_ahead() and SSL_CTX_get_read_ahead() return 0 if reading ahead is off,
  44. and non zero otherwise.
  45. =head1 SEE ALSO
  46. L<ssl(7)>, L<SSL_pending(3)>
  47. =head1 COPYRIGHT
  48. Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
  49. Licensed under the OpenSSL license (the "License"). You may not use
  50. this file except in compliance with the License. You can obtain a copy
  51. in the file LICENSE in the source distribution or at
  52. L<https://www.openssl.org/source/license.html>.
  53. =cut