1BIO_S_FD(3ossl)                     OpenSSL                    BIO_S_FD(3ossl)
2
3
4

NAME

6       BIO_s_fd, BIO_set_fd, BIO_get_fd, BIO_new_fd - file descriptor BIO
7

SYNOPSIS

9        #include <openssl/bio.h>
10
11        const BIO_METHOD *BIO_s_fd(void);
12
13        int BIO_set_fd(BIO *b, int fd, int c);
14        int BIO_get_fd(BIO *b, int *c);
15
16        BIO *BIO_new_fd(int fd, int close_flag);
17

DESCRIPTION

19       BIO_s_fd() returns the file descriptor BIO method. This is a wrapper
20       round the platforms file descriptor routines such as read() and
21       write().
22
23       BIO_read_ex() and BIO_write_ex() read or write the underlying
24       descriptor.  BIO_puts() is supported but BIO_gets() is not.
25
26       If the close flag is set then close() is called on the underlying file
27       descriptor when the BIO is freed.
28
29       BIO_reset() attempts to change the file pointer to the start of file
30       such as by using lseek(fd, 0, 0).
31
32       BIO_seek() sets the file pointer to position ofs from start of file
33       such as by using lseek(fd, ofs, 0).
34
35       BIO_tell() returns the current file position such as by calling
36       lseek(fd, 0, 1).
37
38       BIO_set_fd() sets the file descriptor of BIO b to fd and the close flag
39       to c.
40
41       BIO_get_fd() places the file descriptor of BIO b in c if it is not
42       NULL.  It also returns the file descriptor.
43
44       BIO_new_fd() returns a file descriptor BIO using fd and close_flag.
45

NOTES

47       The behaviour of BIO_read_ex() and BIO_write_ex() depends on the
48       behavior of the platforms read() and write() calls on the descriptor.
49       If the underlying file descriptor is in a non blocking mode then the
50       BIO will behave in the manner described in the BIO_read_ex(3) and
51       BIO_should_retry(3) manual pages.
52
53       File descriptor BIOs should not be used for socket I/O. Use socket BIOs
54       instead.
55
56       BIO_set_fd() and BIO_get_fd() are implemented as macros.
57

RETURN VALUES

59       BIO_s_fd() returns the file descriptor BIO method.
60
61       BIO_set_fd() returns 1 on success or <=0 for failure.
62
63       BIO_get_fd() returns the file descriptor or -1 if the BIO has not been
64       initialized. It also returns zero and negative values if other error
65       occurs.
66
67       BIO_new_fd() returns the newly allocated BIO or NULL is an error
68       occurred.
69

EXAMPLES

71       This is a file descriptor BIO version of "Hello World":
72
73        BIO *out;
74
75        out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE);
76        BIO_printf(out, "Hello World\n");
77        BIO_free(out);
78

SEE ALSO

80       BIO_seek(3), BIO_tell(3), BIO_reset(3), BIO_read_ex(3),
81       BIO_write_ex(3), BIO_puts(3), BIO_gets(3), BIO_printf(3),
82       BIO_set_close(3), BIO_get_close(3)
83
85       Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
86
87       Licensed under the Apache License 2.0 (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
943.0.5                             2022-07-05                   BIO_S_FD(3ossl)
Impressum