2020-03-02 11:50:34 -05:00
|
|
|
<?xml version="1.0" ?>
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<head>
|
|
|
|
<title>BIO_connect</title>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
|
|
|
<link rev="made" href="mailto:root@localhost" />
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body style="background-color: white">
|
|
|
|
|
|
|
|
|
|
|
|
<!-- INDEX BEGIN -->
|
|
|
|
<div name="index">
|
|
|
|
<p><a name="__index__"></a></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li><a href="#name">NAME</a></li>
|
|
|
|
<li><a href="#synopsis">SYNOPSIS</a></li>
|
|
|
|
<li><a href="#description">DESCRIPTION</a></li>
|
|
|
|
<li><a href="#flags">FLAGS</a></li>
|
|
|
|
<li><a href="#return_values">RETURN VALUES</a></li>
|
|
|
|
<li><a href="#see_also">SEE ALSO</a></li>
|
|
|
|
<li><a href="#history">HISTORY</a></li>
|
|
|
|
<li><a href="#copyright">COPYRIGHT</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<hr name="index" />
|
|
|
|
</div>
|
|
|
|
<!-- INDEX END -->
|
|
|
|
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="name">NAME</a></h1>
|
|
|
|
<p>BIO_socket, BIO_bind, BIO_connect, BIO_listen, BIO_accept_ex, BIO_closesocket - BIO
|
|
|
|
socket communication setup routines</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
|
|
|
<pre>
|
|
|
|
#include <openssl/bio.h></pre>
|
|
|
|
<pre>
|
|
|
|
int BIO_socket(int domain, int socktype, int protocol, int options);
|
|
|
|
int BIO_bind(int sock, const BIO_ADDR *addr, int options);
|
|
|
|
int BIO_connect(int sock, const BIO_ADDR *addr, int options);
|
|
|
|
int BIO_listen(int sock, const BIO_ADDR *addr, int options);
|
|
|
|
int BIO_accept_ex(int accept_sock, BIO_ADDR *peer, int options);
|
|
|
|
int BIO_closesocket(int sock);</pre>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="description">DESCRIPTION</a></h1>
|
|
|
|
<p><code>BIO_socket()</code> creates a socket in the domain <strong>domain</strong>, of type
|
|
|
|
<strong>socktype</strong> and <strong>protocol</strong>. Socket <strong>options</strong> are currently unused,
|
|
|
|
but is present for future use.</p>
|
|
|
|
<p><code>BIO_bind()</code> binds the source address and service to a socket and
|
|
|
|
may be useful before calling <code>BIO_connect()</code>. The options may include
|
|
|
|
<strong>BIO_SOCK_REUSEADDR</strong>, which is described in <a href="#flags">FLAGS</a> below.</p>
|
|
|
|
<p><code>BIO_connect()</code> connects <strong>sock</strong> to the address and service given by
|
|
|
|
<strong>addr</strong>. Connection <strong>options</strong> may be zero or any combination of
|
|
|
|
<strong>BIO_SOCK_KEEPALIVE</strong>, <strong>BIO_SOCK_NONBLOCK</strong> and <strong>BIO_SOCK_NODELAY</strong>.
|
|
|
|
The flags are described in <a href="#flags">FLAGS</a> below.</p>
|
|
|
|
<p><code>BIO_listen()</code> has <strong>sock</strong> start listening on the address and service
|
|
|
|
given by <strong>addr</strong>. Connection <strong>options</strong> may be zero or any
|
|
|
|
combination of <strong>BIO_SOCK_KEEPALIVE</strong>, <strong>BIO_SOCK_NONBLOCK</strong>,
|
|
|
|
<strong>BIO_SOCK_NODELAY</strong>, <strong>BIO_SOCK_REUSEADDR</strong> and <strong>BIO_SOCK_V6_ONLY</strong>.
|
|
|
|
The flags are described in <a href="#flags">FLAGS</a> below.</p>
|
|
|
|
<p><code>BIO_accept_ex()</code> waits for an incoming connections on the given
|
|
|
|
socket <strong>accept_sock</strong>. When it gets a connection, the address and
|
|
|
|
port of the peer gets stored in <strong>peer</strong> if that one is non-NULL.
|
|
|
|
Accept <strong>options</strong> may be zero or <strong>BIO_SOCK_NONBLOCK</strong>, and is applied
|
|
|
|
on the accepted socket. The flags are described in <a href="#flags">FLAGS</a> below.</p>
|
|
|
|
<p><code>BIO_closesocket()</code> closes <strong>sock</strong>.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="flags">FLAGS</a></h1>
|
|
|
|
<dl>
|
|
|
|
<dt><strong><a name="bio_sock_keepalive" class="item">BIO_SOCK_KEEPALIVE</a></strong></dt>
|
|
|
|
|
|
|
|
<dd>
|
|
|
|
<p>Enables regular sending of keep-alive messages.</p>
|
|
|
|
</dd>
|
|
|
|
<dt><strong><a name="bio_sock_nonblock" class="item">BIO_SOCK_NONBLOCK</a></strong></dt>
|
|
|
|
|
|
|
|
<dd>
|
|
|
|
<p>Sets the socket to non-blocking mode.</p>
|
|
|
|
</dd>
|
|
|
|
<dt><strong><a name="bio_sock_nodelay" class="item">BIO_SOCK_NODELAY</a></strong></dt>
|
|
|
|
|
|
|
|
<dd>
|
|
|
|
<p>Corresponds to <strong>TCP_NODELAY</strong>, and disables the Nagle algorithm. With
|
|
|
|
this set, any data will be sent as soon as possible instead of being
|
|
|
|
buffered until there's enough for the socket to send out in one go.</p>
|
|
|
|
</dd>
|
|
|
|
<dt><strong><a name="bio_sock_reuseaddr" class="item">BIO_SOCK_REUSEADDR</a></strong></dt>
|
|
|
|
|
|
|
|
<dd>
|
|
|
|
<p>Try to reuse the address and port combination for a recently closed
|
|
|
|
port.</p>
|
|
|
|
</dd>
|
|
|
|
<dt><strong><a name="bio_sock_v6_only" class="item">BIO_SOCK_V6_ONLY</a></strong></dt>
|
|
|
|
|
|
|
|
<dd>
|
|
|
|
<p>When creating an IPv6 socket, make it only listen for IPv6 addresses
|
|
|
|
and not IPv4 addresses mapped to IPv6.</p>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
<p>These flags are bit flags, so they are to be combined with the
|
|
|
|
<code>|</code> operator, for example:</p>
|
|
|
|
<pre>
|
|
|
|
BIO_connect(sock, addr, BIO_SOCK_KEEPALIVE | BIO_SOCK_NONBLOCK);</pre>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="return_values">RETURN VALUES</a></h1>
|
|
|
|
<p><code>BIO_socket()</code> returns the socket number on success or <strong>INVALID_SOCKET</strong>
|
|
|
|
(-1) on error. When an error has occurred, the OpenSSL error stack
|
|
|
|
will hold the error data and errno has the system error.</p>
|
|
|
|
<p><code>BIO_bind()</code>, <code>BIO_connect()</code> and <code>BIO_listen()</code> return 1 on success or 0 on error.
|
|
|
|
When an error has occurred, the OpenSSL error stack will hold the error
|
|
|
|
data and errno has the system error.</p>
|
|
|
|
<p><code>BIO_accept_ex()</code> returns the accepted socket on success or
|
|
|
|
<strong>INVALID_SOCKET</strong> (-1) on error. When an error has occurred, the
|
|
|
|
OpenSSL error stack will hold the error data and errno has the system
|
|
|
|
error.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="see_also">SEE ALSO</a></h1>
|
|
|
|
<p><em>BIO_ADDR(3)</em></p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="history">HISTORY</a></h1>
|
|
|
|
<p><code>BIO_gethostname()</code>, <code>BIO_get_port()</code>, <code>BIO_get_host_ip()</code>,
|
|
|
|
<code>BIO_get_accept_socket()</code> and <code>BIO_accept()</code> were deprecated in OpenSSL 1.1.0.
|
|
|
|
Use the functions described above instead.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="copyright">COPYRIGHT</a></h1>
|
|
|
|
<p>Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.</p>
|
2020-03-02 12:19:21 -05:00
|
|
|
<p>Licensed under the OpenSSL license (the "License"). You may not use
|
2020-03-02 11:50:34 -05:00
|
|
|
this file except in compliance with the License. You can obtain a copy
|
|
|
|
in the file LICENSE in the source distribution or at
|
|
|
|
<a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|