Blame doc/man3/BIO_read.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
BIO_read_ex, BIO_write_ex, BIO_read, BIO_write, BIO_gets, BIO_puts
Packit c4476c
- BIO I/O functions
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/bio.h>
Packit c4476c
Packit c4476c
 int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);
Packit c4476c
 int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
Packit c4476c
Packit c4476c
 int BIO_read(BIO *b, void *data, int dlen);
Packit c4476c
 int BIO_gets(BIO *b, char *buf, int size);
Packit c4476c
 int BIO_write(BIO *b, const void *data, int dlen);
Packit c4476c
 int BIO_puts(BIO *b, const char *buf);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
BIO_read_ex() attempts to read B<dlen> bytes from BIO B and places the data
Packit c4476c
in B<data>. If any bytes were successfully read then the number of bytes read is
Packit c4476c
stored in B<*readbytes>.
Packit c4476c
Packit c4476c
BIO_write_ex() attempts to write B<dlen> bytes from B<data> to BIO B. If
Packit c4476c
successful then the number of bytes written is stored in B<*written>.
Packit c4476c
Packit c4476c
BIO_read() attempts to read B<len> bytes from BIO B and places
Packit c4476c
the data in B<buf>.
Packit c4476c
Packit c4476c
BIO_gets() performs the BIOs "gets" operation and places the data
Packit c4476c
in B<buf>. Usually this operation will attempt to read a line of data
Packit c4476c
from the BIO of maximum length B<size-1>. There are exceptions to this,
Packit c4476c
however; for example, BIO_gets() on a digest BIO will calculate and
Packit c4476c
return the digest and other BIOs may not support BIO_gets() at all.
Packit c4476c
The returned string is always NUL-terminated and the '\n' is preserved
Packit c4476c
if present in the input data.
Packit c4476c
Packit c4476c
BIO_write() attempts to write B<len> bytes from B<buf> to BIO B.
Packit c4476c
Packit c4476c
BIO_puts() attempts to write a NUL-terminated string B<buf> to BIO B.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
BIO_read_ex() and BIO_write_ex() return 1 if data was successfully read or
Packit c4476c
written, and 0 otherwise.
Packit c4476c
Packit c4476c
All other functions return either the amount of data successfully read or
Packit c4476c
written (if the return value is positive) or that no data was successfully
Packit c4476c
read or written if the result is 0 or -1. If the return value is -2 then
Packit c4476c
the operation is not implemented in the specific BIO type.  The trailing
Packit c4476c
NUL is not included in the length returned by BIO_gets().
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
A 0 or -1 return is not necessarily an indication of an error. In
Packit c4476c
particular when the source/sink is non-blocking or of a certain type
Packit c4476c
it may merely be an indication that no data is currently available and that
Packit c4476c
the application should retry the operation later.
Packit c4476c
Packit c4476c
One technique sometimes used with blocking sockets is to use a system call
Packit c4476c
(such as select(), poll() or equivalent) to determine when data is available
Packit c4476c
and then call read() to read the data. The equivalent with BIOs (that is call
Packit c4476c
select() on the underlying I/O structure and then call BIO_read() to
Packit c4476c
read the data) should B<not> be used because a single call to BIO_read()
Packit c4476c
can cause several reads (and writes in the case of SSL BIOs) on the underlying
Packit c4476c
I/O structure and may block as a result. Instead select() (or equivalent)
Packit c4476c
should be combined with non blocking I/O so successive reads will request
Packit c4476c
a retry instead of blocking.
Packit c4476c
Packit c4476c
See L<BIO_should_retry(3)> for details of how to
Packit c4476c
determine the cause of a retry and other I/O issues.
Packit c4476c
Packit c4476c
If the BIO_gets() function is not supported by a BIO then it possible to
Packit c4476c
work around this by adding a buffering BIO L<BIO_f_buffer(3)>
Packit c4476c
to the chain.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<BIO_should_retry(3)>
Packit c4476c
Packit c4476c
=head1 HISTORY
Packit c4476c
Packit c4476c
BIO_gets() on 1.1.0 and older when called on BIO_fd() based BIO does not
Packit c4476c
keep the '\n' at the end of the line in the buffer.
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut