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