Adds asio library and Storage Module
This commit is contained in:
1 parent
79a6ee5779
commit
30439acd43
4869 files changed
+618801
-903
No files matched your search
@@ -0,0 +1,77 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Fork</title>
|
||||
<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||
<link rel="home" href="../../../index.html" title="Asio">
|
||||
<link rel="up" href="../posix.html" title="POSIX-Specific Functionality">
|
||||
<link rel="prev" href="stream_descriptor.html" title="Stream-Oriented File Descriptors">
|
||||
<link rel="next" href="../windows.html" title="Windows-Specific Functionality">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../../asio.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="stream_descriptor.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../posix.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="../windows.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.posix.fork"></a><a class="link" href="fork.html" title="Fork">Fork</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Asio supports programs that utilise the <code class="computeroutput">fork()</code> system call.
|
||||
Provided the program calls <code class="computeroutput">io_context.notify_fork()</code> at the
|
||||
appropriate times, Asio will recreate any internal file descriptors (such
|
||||
as the "self-pipe trick" descriptor used for waking up a reactor).
|
||||
The notification is usually performed as follows:
|
||||
</p>
|
||||
<pre class="programlisting">io_context_.notify_fork(asio::io_context::fork_prepare);
|
||||
if (fork() == 0)
|
||||
{
|
||||
io_context_.notify_fork(asio::io_context::fork_child);
|
||||
...
|
||||
}
|
||||
else
|
||||
{
|
||||
io_context_.notify_fork(asio::io_context::fork_parent);
|
||||
...
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
User-defined services can also be made fork-aware by overriding the <code class="computeroutput">io_context::service::notify_fork()</code>
|
||||
virtual function.
|
||||
</p>
|
||||
<p>
|
||||
Note that any file descriptors accessible via Asio's public API (e.g. the
|
||||
descriptors underlying <code class="computeroutput">basic_socket<></code>, <code class="computeroutput">posix::stream_descriptor</code>,
|
||||
etc.) are not altered during a fork. It is the program's responsibility
|
||||
to manage these as required.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="asio.overview.posix.fork.h0"></a>
|
||||
<span><a name="asio.overview.posix.fork.see_also"></a></span><a class="link" href="fork.html#asio.overview.posix.fork.see_also">See
|
||||
Also</a>
|
||||
</h6>
|
||||
<p>
|
||||
<a class="link" href="../../reference/io_context/notify_fork.html" title="io_context::notify_fork">io_context::notify_fork()</a>,
|
||||
<a class="link" href="../../reference/io_context/fork_event.html" title="io_context::fork_event">io_context::fork_event</a>,
|
||||
<a class="link" href="../../reference/execution_context__service/notify_fork.html" title="execution_context::service::notify_fork">io_context::service::notify_fork()</a>,
|
||||
<a class="link" href="../../examples/cpp03_examples.html#asio.examples.cpp03_examples.fork">Fork examples</a>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
|
||||
Kohlhoff<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="stream_descriptor.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../posix.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="../windows.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,104 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>UNIX Domain Sockets</title>
|
||||
<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||
<link rel="home" href="../../../index.html" title="Asio">
|
||||
<link rel="up" href="../posix.html" title="POSIX-Specific Functionality">
|
||||
<link rel="prev" href="../posix.html" title="POSIX-Specific Functionality">
|
||||
<link rel="next" href="stream_descriptor.html" title="Stream-Oriented File Descriptors">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../../asio.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../posix.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../posix.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="stream_descriptor.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.posix.local"></a><a class="link" href="local.html" title="UNIX Domain Sockets">UNIX Domain Sockets</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Asio provides basic support for UNIX domain sockets (also known as local
|
||||
sockets). The simplest use involves creating a pair of connected sockets.
|
||||
The following code:
|
||||
</p>
|
||||
<pre class="programlisting">local::stream_protocol::socket socket1(my_io_context);
|
||||
local::stream_protocol::socket socket2(my_io_context);
|
||||
local::connect_pair(socket1, socket2);
|
||||
</pre>
|
||||
<p>
|
||||
will create a pair of stream-oriented sockets. To do the same for datagram-oriented
|
||||
sockets, use:
|
||||
</p>
|
||||
<pre class="programlisting">local::datagram_protocol::socket socket1(my_io_context);
|
||||
local::datagram_protocol::socket socket2(my_io_context);
|
||||
local::connect_pair(socket1, socket2);
|
||||
</pre>
|
||||
<p>
|
||||
A UNIX domain socket server may be created by binding an acceptor to an
|
||||
endpoint, in much the same way as one does for a TCP server:
|
||||
</p>
|
||||
<pre class="programlisting">::unlink("/tmp/foobar"); // Remove previous binding.
|
||||
local::stream_protocol::endpoint ep("/tmp/foobar");
|
||||
local::stream_protocol::acceptor acceptor(my_io_context, ep);
|
||||
local::stream_protocol::socket socket(my_io_context);
|
||||
acceptor.accept(socket);
|
||||
</pre>
|
||||
<p>
|
||||
A client that connects to this server might look like:
|
||||
</p>
|
||||
<pre class="programlisting">local::stream_protocol::endpoint ep("/tmp/foobar");
|
||||
local::stream_protocol::socket socket(my_io_context);
|
||||
socket.connect(ep);
|
||||
</pre>
|
||||
<p>
|
||||
Transmission of file descriptors or credentials across UNIX domain sockets
|
||||
is not directly supported within Asio, but may be achieved by accessing
|
||||
the socket's underlying descriptor using the <a class="link" href="../../reference/basic_socket/native_handle.html" title="basic_socket::native_handle">native_handle()</a>
|
||||
member function.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="asio.overview.posix.local.h0"></a>
|
||||
<span><a name="asio.overview.posix.local.see_also"></a></span><a class="link" href="local.html#asio.overview.posix.local.see_also">See
|
||||
Also</a>
|
||||
</h6>
|
||||
<p>
|
||||
<a class="link" href="../../reference/local__connect_pair.html" title="local::connect_pair">local::connect_pair</a>,
|
||||
<a class="link" href="../../reference/local__datagram_protocol.html" title="local::datagram_protocol">local::datagram_protocol</a>,
|
||||
<a class="link" href="../../reference/local__datagram_protocol/endpoint.html" title="local::datagram_protocol::endpoint">local::datagram_protocol::endpoint</a>,
|
||||
<a class="link" href="../../reference/local__datagram_protocol/socket.html" title="local::datagram_protocol::socket">local::datagram_protocol::socket</a>,
|
||||
<a class="link" href="../../reference/local__stream_protocol.html" title="local::stream_protocol">local::stream_protocol</a>,
|
||||
<a class="link" href="../../reference/local__stream_protocol/acceptor.html" title="local::stream_protocol::acceptor">local::stream_protocol::acceptor</a>,
|
||||
<a class="link" href="../../reference/local__stream_protocol/endpoint.html" title="local::stream_protocol::endpoint">local::stream_protocol::endpoint</a>,
|
||||
<a class="link" href="../../reference/local__stream_protocol/iostream.html" title="local::stream_protocol::iostream">local::stream_protocol::iostream</a>,
|
||||
<a class="link" href="../../reference/local__stream_protocol/socket.html" title="local::stream_protocol::socket">local::stream_protocol::socket</a>,
|
||||
<a class="link" href="../../examples/cpp03_examples.html#asio.examples.cpp03_examples.unix_domain_sockets">UNIX domain
|
||||
sockets examples</a>.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="asio.overview.posix.local.h1"></a>
|
||||
<span><a name="asio.overview.posix.local.notes"></a></span><a class="link" href="local.html#asio.overview.posix.local.notes">Notes</a>
|
||||
</h6>
|
||||
<p>
|
||||
UNIX domain sockets are only available at compile time if supported by
|
||||
the target operating system. A program may test for the macro <code class="computeroutput">ASIO_HAS_LOCAL_SOCKETS</code>
|
||||
to determine whether they are supported.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
|
||||
Kohlhoff<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../posix.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../posix.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="stream_descriptor.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,86 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Stream-Oriented File Descriptors</title>
|
||||
<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||
<link rel="home" href="../../../index.html" title="Asio">
|
||||
<link rel="up" href="../posix.html" title="POSIX-Specific Functionality">
|
||||
<link rel="prev" href="local.html" title="UNIX Domain Sockets">
|
||||
<link rel="next" href="fork.html" title="Fork">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../../asio.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="local.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../posix.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="fork.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.posix.stream_descriptor"></a><a class="link" href="stream_descriptor.html" title="Stream-Oriented File Descriptors">Stream-Oriented
|
||||
File Descriptors</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Asio includes classes added to permit synchronous and asynchronous read
|
||||
and write operations to be performed on POSIX file descriptors, such as
|
||||
pipes, standard input and output, and various devices.
|
||||
</p>
|
||||
<p>
|
||||
These classes also provide limited support for regular files. This support
|
||||
assumes that the underlying read and write operations provided by the operating
|
||||
system never fail with <code class="computeroutput">EAGAIN</code> or <code class="computeroutput">EWOULDBLOCK</code>.
|
||||
(This assumption normally holds for buffered file I/O.) Synchronous and
|
||||
asynchronous read and write operations on file descriptors will succeed
|
||||
but the I/O will always be performed immediately. Wait operations, and
|
||||
operations involving <code class="computeroutput">asio::null_buffers</code>, are not portably
|
||||
supported.
|
||||
</p>
|
||||
<p>
|
||||
For example, to perform read and write operations on standard input and
|
||||
output, the following objects may be created:
|
||||
</p>
|
||||
<pre class="programlisting">posix::stream_descriptor in(my_io_context, ::dup(STDIN_FILENO));
|
||||
posix::stream_descriptor out(my_io_context, ::dup(STDOUT_FILENO));
|
||||
</pre>
|
||||
<p>
|
||||
These are then used as synchronous or asynchronous read and write streams.
|
||||
This means the objects can be used with any of the <a class="link" href="../../reference/read.html" title="read">read()</a>,
|
||||
<a class="link" href="../../reference/async_read.html" title="async_read">async_read()</a>, <a class="link" href="../../reference/write.html" title="write">write()</a>,
|
||||
<a class="link" href="../../reference/async_write.html" title="async_write">async_write()</a>, <a class="link" href="../../reference/read_until.html" title="read_until">read_until()</a> or <a class="link" href="../../reference/async_read_until.html" title="async_read_until">async_read_until()</a>
|
||||
free functions.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="asio.overview.posix.stream_descriptor.h0"></a>
|
||||
<span><a name="asio.overview.posix.stream_descriptor.see_also"></a></span><a class="link" href="stream_descriptor.html#asio.overview.posix.stream_descriptor.see_also">See
|
||||
Also</a>
|
||||
</h6>
|
||||
<p>
|
||||
<a class="link" href="../../reference/posix__stream_descriptor.html" title="posix::stream_descriptor">posix::stream_descriptor</a>,
|
||||
<a class="link" href="../../examples/cpp03_examples.html#asio.examples.cpp03_examples.chat">Chat example (C++03)</a>,
|
||||
<a class="link" href="../../examples/cpp11_examples.html#asio.examples.cpp11_examples.chat">Chat example (C++11)</a>.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="asio.overview.posix.stream_descriptor.h1"></a>
|
||||
<span><a name="asio.overview.posix.stream_descriptor.notes"></a></span><a class="link" href="stream_descriptor.html#asio.overview.posix.stream_descriptor.notes">Notes</a>
|
||||
</h6>
|
||||
<p>
|
||||
POSIX stream descriptors are only available at compile time if supported
|
||||
by the target operating system. A program may test for the macro <code class="computeroutput">ASIO_HAS_POSIX_STREAM_DESCRIPTOR</code>
|
||||
to determine whether they are supported.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
|
||||
Kohlhoff<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="local.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../posix.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="fork.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user