]> git.ipfire.org Git - thirdparty/openssl.git/blob - doc/man3/SSL_set_fd.pod
6e0ab578e67311f8689366340006d2dc7f754499
[thirdparty/openssl.git] / doc / man3 / SSL_set_fd.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_set_fd, SSL_set_rfd, SSL_set_wfd - connect the SSL object with a file descriptor
6
7 =head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_set_fd(SSL *ssl, int fd);
12 int SSL_set_rfd(SSL *ssl, int fd);
13 int SSL_set_wfd(SSL *ssl, int fd);
14
15 =head1 DESCRIPTION
16
17 SSL_set_fd() sets the file descriptor B<fd> as the input/output facility
18 for the TLS/SSL (encrypted) side of B<ssl>. B<fd> will typically be the
19 socket file descriptor of a network connection.
20
21 When performing the operation, a B<socket BIO> is automatically created to
22 interface between the B<ssl> and B<fd>. The BIO and hence the SSL engine
23 inherit the behaviour of B<fd>. If B<fd> is nonblocking, the B<ssl> will
24 also have nonblocking behaviour.
25
26 When used on a QUIC SSL object, a B<datagram BIO> is automatically created
27 instead of a B<socket BIO>.
28
29 If there was already a BIO connected to B<ssl>, BIO_free() will be called
30 (for both the reading and writing side, if different).
31
32 SSL_set_rfd() and SSL_set_wfd() perform the respective action, but only
33 for the read channel or the write channel, which can be set independently.
34
35 =head1 RETURN VALUES
36
37 The following return values can occur:
38
39 =over 4
40
41 =item Z<>0
42
43 The operation failed. Check the error stack to find out why.
44
45 =item Z<>1
46
47 The operation succeeded.
48
49 =back
50
51 =head1 NOTES
52
53 On Windows, a socket handle is a 64-bit data type (UINT_PTR), which leads to a
54 compiler warning (conversion from 'SOCKET' to 'int', possible loss of data) when
55 passing the socket handle to SSL_set_*fd(). For the time being, this warning can
56 safely be ignored, because although the Microsoft documentation claims that the
57 upper limit is INVALID_SOCKET-1 (2^64 - 2), in practice the current socket()
58 implementation returns an index into the kernel handle table, the size of which
59 is limited to 2^24.
60
61
62 =head1 SEE ALSO
63
64 L<SSL_get_fd(3)>, L<SSL_set_bio(3)>,
65 L<SSL_connect(3)>, L<SSL_accept(3)>,
66 L<SSL_shutdown(3)>, L<ssl(7)> , L<bio(7)>
67
68 =head1 COPYRIGHT
69
70 Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
71
72 Licensed under the Apache License 2.0 (the "License"). You may not use
73 this file except in compliance with the License. You can obtain a copy
74 in the file LICENSE in the source distribution or at
75 L<https://www.openssl.org/source/license.html>.
76
77 =cut