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

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

<h1>BIO_s_socket(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="#NOTES">NOTES</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>
BIO_s_socket, BIO_new_socket - socket BIO

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/bio.h&gt;
</PRE>
<PRE> BIO_METHOD *BIO_s_socket(void);
</PRE>
<PRE> long BIO_set_fd(BIO *b, int fd, long close_flag);
 long BIO_get_fd(BIO *b, int *c);
</PRE>
<PRE> BIO *BIO_new_socket(int sock, int close_flag);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>BIO_s_socket()</CODE> returns the socket BIO method. This is a
wrapper round the platform's socket routines.

</P>
<P>
<CODE>BIO_read()</CODE> and <CODE>BIO_write()</CODE> read or write the
underlying socket. <CODE>BIO_puts()</CODE> is supported but
<CODE>BIO_gets()</CODE> is not.

</P>
<P>
If the close flag is set then the socket is shut down and closed when the
BIO is freed.

</P>
<P>
<CODE>BIO_set_fd()</CODE> sets the socket of BIO <STRONG>b</STRONG> to <STRONG>fd</STRONG> and the close flag to <STRONG>close_flag</STRONG>.

</P>
<P>
<CODE>BIO_get_fd()</CODE> places the socket in <STRONG>c</STRONG> if it is not NULL, it also returns the socket. If <STRONG>c</STRONG> is not NULL it should be of type (int *).

</P>
<P>
<CODE>BIO_new_socket()</CODE> returns a socket BIO using <STRONG>sock</STRONG> and <STRONG>close_flag</STRONG>.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
Socket BIOs also support any relevant functionality of file descriptor
BIOs.

</P>
<P>
The reason for having separate file descriptor and socket BIOs is that on
some platforms sockets are not file descriptors and use distinct I/O
routines, Windows is one such platform. Any code mixing the two will not
work on all platforms.

</P>
<P>
<CODE>BIO_set_fd()</CODE> and <CODE>BIO_get_fd()</CODE> are macros.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>BIO_s_socket()</CODE> returns the socket BIO method.

</P>
<P>
<CODE>BIO_set_fd()</CODE> always returns 1.

</P>
<P>
<CODE>BIO_get_fd()</CODE> returns the socket or -1 if the BIO has not been
initialized.

</P>
<P>
<CODE>BIO_new_socket()</CODE> returns the newly allocated BIO or NULL is an
error occurred.

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
TBA
</P>
:}

