
#use wml::openssl-macros area=docs page=SSL_set_fd

<title>Documents, SSL_set_fd(3)</title>

<h1>SSL_set_fd(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
SSL_set_fd - connect the SSL object with a file descriptor

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/ssl.h&gt;
</PRE>
<PRE> int SSL_set_fd(SSL *ssl, int fd);
 int SSL_set_rfd(SSL *ssl, int fd);
 int SSL_set_wfd(SSL *ssl, int fd);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>SSL_set_fd()</CODE> sets the file descriptor <STRONG>fd</STRONG> as the input/output facility for the TLS/SSL (encrypted) side of <STRONG>ssl</STRONG>. <STRONG>fd</STRONG> will typically be the socket file descriptor of a network connection.

</P>
<P>
When performing the operation, a <STRONG>socket BIO</STRONG> is automatically created to interface between the <STRONG>ssl</STRONG> and <STRONG>fd</STRONG>. The BIO and hence the SSL engine inherit the behaviour of <STRONG>fd</STRONG>. If <STRONG>fd</STRONG> is non-blocking, the <STRONG>ssl</STRONG> will also have non-blocking behaviour.

</P>
<P>
If there was already a BIO connected to <STRONG>ssl</STRONG>, <CODE>BIO_free()</CODE> will be called (for both the reading and writing
side, if different).

</P>
<P>
<CODE>SSL_set_rfd()</CODE> and <CODE>SSL_set_wfd()</CODE> perform the
respective action, but only for the read channel or the write channel,
which can be set independently.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
The following return values can occur:

</P>
<DL>
<DT><STRONG><A NAME="item_0">0</A></STRONG><DD>
<P>
The operation failed. Check the error stack to find out why.

</P>
<DT><STRONG><A NAME="item_1">1</A></STRONG><DD>
<P>
The operation succeeded.

</P>
</DL>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../ssl/SSL_get_fd.html#">SSL_get_fd(3)</A>, <A HREF="../ssl/SSL_set_bio.html#">SSL_set_bio(3)</A>,
<A HREF="../ssl/SSL_connect.html#">SSL_connect(3)</A>, <A HREF="../ssl/SSL_accept.html#">SSL_accept(3)</A>,
<A HREF="../ssl/SSL_shutdown.html#">SSL_shutdown(3)</A>, <A HREF="../ssl/ssl.html#">ssl(3)</A> , <A HREF="../crypto/bio.html#">bio(3)</A>



</P>
:}


