1BIO_READ(3)                         OpenSSL                        BIO_READ(3)
2
3
4

NAME

6       BIO_read_ex, BIO_write_ex, BIO_read, BIO_write, BIO_gets, BIO_puts -
7       BIO I/O functions
8

SYNOPSIS

10        #include <openssl/bio.h>
11
12        int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);
13        int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
14
15        int BIO_read(BIO *b, void *data, int dlen);
16        int BIO_gets(BIO *b, char *buf, int size);
17        int BIO_write(BIO *b, const void *data, int dlen);
18        int BIO_puts(BIO *b, const char *buf);
19

DESCRIPTION

21       BIO_read_ex() attempts to read dlen bytes from BIO b and places the
22       data in data. If any bytes were successfully read then the number of
23       bytes read is stored in *readbytes.
24
25       BIO_write_ex() attempts to write dlen bytes from data to BIO b. If
26       successful then the number of bytes written is stored in *written.
27
28       BIO_read() attempts to read len bytes from BIO b and places the data in
29       buf.
30
31       BIO_gets() performs the BIOs "gets" operation and places the data in
32       buf. Usually this operation will attempt to read a line of data from
33       the BIO of maximum length size-1. There are exceptions to this,
34       however; for example, BIO_gets() on a digest BIO will calculate and
35       return the digest and other BIOs may not support BIO_gets() at all.
36       The returned string is always NUL-terminated and the '\n' is preserved
37       if present in the input data.
38
39       BIO_write() attempts to write len bytes from buf to BIO b.
40
41       BIO_puts() attempts to write a NUL-terminated string buf to BIO b.
42

RETURN VALUES

44       BIO_read_ex() and BIO_write_ex() return 1 if data was successfully read
45       or written, and 0 otherwise.
46
47       All other functions return either the amount of data successfully read
48       or written (if the return value is positive) or that no data was
49       successfully read or written if the result is 0 or -1. If the return
50       value is -2 then the operation is not implemented in the specific BIO
51       type.  The trailing NUL is not included in the length returned by
52       BIO_gets().
53

NOTES

55       A 0 or -1 return is not necessarily an indication of an error. In
56       particular when the source/sink is nonblocking or of a certain type it
57       may merely be an indication that no data is currently available and
58       that the application should retry the operation later.
59
60       One technique sometimes used with blocking sockets is to use a system
61       call (such as select(), poll() or equivalent) to determine when data is
62       available and then call read() to read the data. The equivalent with
63       BIOs (that is call select() on the underlying I/O structure and then
64       call BIO_read() to read the data) should not be used because a single
65       call to BIO_read() can cause several reads (and writes in the case of
66       SSL BIOs) on the underlying I/O structure and may block as a result.
67       Instead select() (or equivalent) should be combined with non blocking
68       I/O so successive reads will request a retry instead of blocking.
69
70       See BIO_should_retry(3) for details of how to determine the cause of a
71       retry and other I/O issues.
72
73       If the BIO_gets() function is not supported by a BIO then it possible
74       to work around this by adding a buffering BIO BIO_f_buffer(3) to the
75       chain.
76

SEE ALSO

78       BIO_should_retry(3)
79

HISTORY

81       BIO_gets() on 1.1.0 and older when called on BIO_fd() based BIO does
82       not keep the '\n' at the end of the line in the buffer.
83
85       Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
86
87       Licensed under the OpenSSL license (the "License").  You may not use
88       this file except in compliance with the License.  You can obtain a copy
89       in the file LICENSE in the source distribution or at
90       <https://www.openssl.org/source/license.html>.
91
92
93
941.1.1i                            2021-07-22                       BIO_READ(3)
Impressum