openssl-prebuild/linux_amd64/share/doc/openssl/html/man3/BIO_read.html

130 lines
5.5 KiB
HTML
Raw Normal View History

2020-03-02 11:50:34 -05:00
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BIO_read</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#return_values">RETURN VALUES</a></li>
<li><a href="#notes">NOTES</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
<li><a href="#history">HISTORY</a></li>
<li><a href="#copyright">COPYRIGHT</a></li>
</ul>
<hr name="index" />
</div>
<!-- INDEX END -->
<p>
</p>
<hr />
<h1><a name="name">NAME</a></h1>
<p>BIO_read_ex, BIO_write_ex, BIO_read, BIO_write, BIO_gets, BIO_puts
- BIO I/O functions</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
#include &lt;openssl/bio.h&gt;</pre>
<pre>
int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);
int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);</pre>
<pre>
int BIO_read(BIO *b, void *data, int dlen);
int BIO_gets(BIO *b, char *buf, int size);
int BIO_write(BIO *b, const void *data, int dlen);
int BIO_puts(BIO *b, const char *buf);</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p><code>BIO_read_ex()</code> attempts to read <strong>dlen</strong> bytes from BIO <strong>b</strong> and places the data
in <strong>data</strong>. If any bytes were successfully read then the number of bytes read is
stored in <strong>*readbytes</strong>.</p>
<p><code>BIO_write_ex()</code> attempts to write <strong>dlen</strong> bytes from <strong>data</strong> to BIO <strong>b</strong>. If
successful then the number of bytes written is stored in <strong>*written</strong>.</p>
<p><code>BIO_read()</code> attempts to read <strong>len</strong> bytes from BIO <strong>b</strong> and places
the data in <strong>buf</strong>.</p>
<p><code>BIO_gets()</code> performs the BIOs &quot;gets&quot; operation and places the data
in <strong>buf</strong>. Usually this operation will attempt to read a line of data
from the BIO of maximum length <strong>size-1</strong>. There are exceptions to this,
however; for example, <code>BIO_gets()</code> on a digest BIO will calculate and
return the digest and other BIOs may not support <code>BIO_gets()</code> at all.
The returned string is always NUL-terminated and the '\n' is preserved
if present in the input data.</p>
<p><code>BIO_write()</code> attempts to write <strong>len</strong> bytes from <strong>buf</strong> to BIO <strong>b</strong>.</p>
<p><code>BIO_puts()</code> attempts to write a NUL-terminated string <strong>buf</strong> to BIO <strong>b</strong>.</p>
<p>
</p>
<hr />
<h1><a name="return_values">RETURN VALUES</a></h1>
<p><code>BIO_read_ex()</code> and <code>BIO_write_ex()</code> return 1 if data was successfully read or
written, and 0 otherwise.</p>
<p>All other functions return either the amount of data successfully read or
written (if the return value is positive) or that no data was successfully
read or written if the result is 0 or -1. If the return value is -2 then
the operation is not implemented in the specific BIO type. The trailing
NUL is not included in the length returned by <code>BIO_gets()</code>.</p>
<p>
</p>
<hr />
<h1><a name="notes">NOTES</a></h1>
<p>A 0 or -1 return is not necessarily an indication of an error. In
particular when the source/sink is non-blocking or of a certain type
it may merely be an indication that no data is currently available and that
the application should retry the operation later.</p>
<p>One technique sometimes used with blocking sockets is to use a system call
(such as <code>select()</code>, <code>poll()</code> or equivalent) to determine when data is available
and then call <code>read()</code> to read the data. The equivalent with BIOs (that is call
<code>select()</code> on the underlying I/O structure and then call <code>BIO_read()</code> to
read the data) should <strong>not</strong> be used because a single call to <code>BIO_read()</code>
can cause several reads (and writes in the case of SSL BIOs) on the underlying
I/O structure and may block as a result. Instead <code>select()</code> (or equivalent)
should be combined with non blocking I/O so successive reads will request
a retry instead of blocking.</p>
<p>See <em>BIO_should_retry(3)</em> for details of how to
determine the cause of a retry and other I/O issues.</p>
<p>If the <code>BIO_gets()</code> function is not supported by a BIO then it possible to
work around this by adding a buffering BIO <em>BIO_f_buffer(3)</em>
to the chain.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><em>BIO_should_retry(3)</em></p>
<p>
</p>
<hr />
<h1><a name="history">HISTORY</a></h1>
<p><code>BIO_gets()</code> on 1.1.0 and older when called on <code>BIO_fd()</code> based BIO does not
keep the '\n' at the end of the line in the buffer.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.</p>
2020-03-02 12:19:21 -05:00
<p>Licensed under the OpenSSL license (the &quot;License&quot;). You may not use
2020-03-02 11:50:34 -05:00
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
<a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
</body>
</html>