1BIO_S_FD(3) OpenSSL BIO_S_FD(3)
2
3
4
6 BIO_s_fd, BIO_set_fd, BIO_get_fd, BIO_new_fd - file descriptor BIO
7
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
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 in c if it is not NULL, it also
42 returns the file descriptor.
43
44 BIO_new_fd() returns a file descriptor BIO using fd and close_flag.
45
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
59 BIO_s_fd() returns the file descriptor BIO method.
60
61 BIO_set_fd() always returns 1.
62
63 BIO_get_fd() returns the file descriptor or -1 if the BIO has not been
64 initialized.
65
66 BIO_new_fd() returns the newly allocated BIO or NULL is an error
67 occurred.
68
70 This is a file descriptor BIO version of "Hello World":
71
72 BIO *out;
73
74 out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE);
75 BIO_printf(out, "Hello World\n");
76 BIO_free(out);
77
79 BIO_seek(3), BIO_tell(3), BIO_reset(3), BIO_read_ex(3),
80 BIO_write_ex(3), BIO_puts(3), BIO_gets(3), BIO_printf(3),
81 BIO_set_close(3), BIO_get_close(3)
82
84 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
85
86 Licensed under the OpenSSL license (the "License"). You may not use
87 this file except in compliance with the License. You can obtain a copy
88 in the file LICENSE in the source distribution or at
89 <https://www.openssl.org/source/license.html>.
90
91
92
931.1.1i 2021-07-22 BIO_S_FD(3)