/
BirdLeon
/
ROBLOX2016
Обзор
Документация
Войти
/
BirdLeon
/
ROBLOX2016
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
Library/cpp-netlib/libs/network/doc/html/index.html
205 строк
13 KB
PatoFlamejanteTV
full source code
19 дек 2024, 19:11
19 дек 2024, 19:11
05db15d
Код
Авторство
О чём код?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Getting cpp-netlib — cpp-netlib v0.13.0</title> <link rel="stylesheet" href="_static/pyramid.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: './', VERSION: '0.13.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="What’s New" href="whats_new.html" /> <link rel="prev" title="Contents" href="contents.html" /> <!--[if lte IE 6]> <link rel="stylesheet" href="_static/ie6.css" type="text/css" media="screen" charset="utf-8" /> <![endif]--> </head> <body role="document"> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="whats_new.html" title="What’s New" accesskey="N">next</a></li> <li class="right" > <a href="contents.html" title="Contents" accesskey="P">previous</a> |</li> <li class="nav-item nav-item-0"><a href="contents.html">cpp-netlib v0.13.0</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <p class="rubric" id="index">Straightforward network programming in modern C++</p> <div class="section" id="getting-cpp-netlib"> <h1>Getting cpp-netlib<a class="headerlink" href="#getting-cpp-netlib" title="Permalink to this headline">¶</a></h1> <p>You can find out more about the <code class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></code> project at <a class="reference external" href="http://cpp-netlib.org/">http://cpp-netlib.org/</a>.</p> <p><strong>Download</strong></p> <p>You can get the latest official version of the library from the official project website at:</p> <blockquote> <div><a class="reference external" href="http://cpp-netlib.org/">http://cpp-netlib.org/</a></div></blockquote> <p>This version of <code class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></code> is tagged as cpp-netlib-0.13.0 in the <a class="reference external" href="http://github.com/">GitHub</a> repository. You can find more information about the progress of the development by checking our <a class="reference external" href="http://github.com/">GitHub</a> project page at:</p> <blockquote> <div><a class="reference external" href="http://github.com/cpp-netlib/cpp-netlib">http://github.com/cpp-netlib/cpp-netlib</a></div></blockquote> <p><strong>Support</strong></p> <p>You can ask questions, join the discussion, and report issues to the developers mailing list by joining via:</p> <blockquote> <div><a class="reference external" href="https://groups.google.com/group/cpp-netlib">https://groups.google.com/group/cpp-netlib</a></div></blockquote> <p>You can also file issues on the <a class="reference external" href="http://github.com/">Github</a> issue tracker at:</p> <blockquote> <div><a class="reference external" href="http://github.com/cpp-netlib/cpp-netlib/issues">http://github.com/cpp-netlib/cpp-netlib/issues</a></div></blockquote> <p>We are a growing community and we are happy to accept new contributions and ideas.</p> </div> <div class="section" id="c-network-library"> <h1>C++ Network Library<a class="headerlink" href="#c-network-library" title="Permalink to this headline">¶</a></h1> <p><code class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></code> is a library collection that provides application layer protocol support using modern C++ techniques. It is light-weight, fast, portable and is intended to be as easy to configure as possible.</p> </div> <div class="section" id="hello-world"> <h1>Hello, world!<a class="headerlink" href="#hello-world" title="Permalink to this headline">¶</a></h1> <p>The <code class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></code> allows developers to write fast, portable network applications with the minimum of fuss.</p> <p>An HTTP server-client example can be written in tens of lines of code. The client is as simple as this:</p> <div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">network</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">network</span><span class="o">::</span><span class="n">http</span><span class="p">;</span> <span class="n">client</span><span class="o">::</span><span class="n">request</span> <span class="n">request_</span><span class="p">(</span><span class="s">"http://127.0.0.1:8000/"</span><span class="p">);</span> <span class="n">request_</span> <span class="o"><<</span> <span class="n">header</span><span class="p">(</span><span class="s">"Connection"</span><span class="p">,</span> <span class="s">"close"</span><span class="p">);</span> <span class="n">client</span> <span class="n">client_</span><span class="p">;</span> <span class="n">client</span><span class="o">::</span><span class="n">response</span> <span class="n">response_</span> <span class="o">=</span> <span class="n">client_</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="n">request_</span><span class="p">);</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">body_</span> <span class="o">=</span> <span class="n">body</span><span class="p">(</span><span class="n">response_</span><span class="p">);</span> </pre></div> </div> <p>And the corresponding server code is listed below:</p> <div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">http</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">network</span><span class="o">::</span><span class="n">http</span><span class="p">;</span> <span class="k">struct</span> <span class="n">handler</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">http</span><span class="o">::</span><span class="n">server</span><span class="o"><</span><span class="n">handler</span><span class="o">></span> <span class="n">http_server</span><span class="p">;</span> <span class="k">struct</span> <span class="n">handler</span> <span class="p">{</span> <span class="kt">void</span> <span class="k">operator</span><span class="p">()</span> <span class="p">(</span><span class="n">http_server</span><span class="o">::</span><span class="n">request</span> <span class="k">const</span> <span class="o">&</span><span class="n">request</span><span class="p">,</span> <span class="n">http_server</span><span class="o">::</span><span class="n">response</span> <span class="o">&</span><span class="n">response</span><span class="p">)</span> <span class="p">{</span> <span class="n">response</span> <span class="o">=</span> <span class="n">http_server</span><span class="o">::</span><span class="n">response</span><span class="o">::</span><span class="n">stock_reply</span><span class="p">(</span> <span class="n">http_server</span><span class="o">::</span><span class="n">response</span><span class="o">::</span><span class="n">ok</span><span class="p">,</span> <span class="s">"Hello, world!"</span><span class="p">);</span> <span class="p">}</span> <span class="kt">void</span> <span class="n">log</span><span class="p">(</span><span class="n">http_server</span><span class="o">::</span><span class="n">string_type</span> <span class="k">const</span> <span class="o">&</span><span class="n">info</span><span class="p">)</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">cerr</span> <span class="o"><<</span> <span class="s">"ERROR: "</span> <span class="o"><<</span> <span class="n">info</span> <span class="o"><<</span> <span class="sc">'\n'</span><span class="p">;</span> <span class="p">}</span> <span class="p">};</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">arg</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">argv</span><span class="p">[])</span> <span class="p">{</span> <span class="n">handler</span> <span class="n">handler_</span><span class="p">;</span> <span class="n">http_server</span><span class="o">::</span><span class="n">options</span> <span class="n">options</span><span class="p">(</span><span class="n">handler_</span><span class="p">);</span> <span class="n">http_server</span> <span class="n">server_</span><span class="p">(</span> <span class="n">options</span><span class="p">.</span><span class="n">address</span><span class="p">(</span><span class="s">"0.0.0.0"</span><span class="p">)</span> <span class="p">.</span><span class="n">port</span><span class="p">(</span><span class="s">"8000"</span><span class="p">));</span> <span class="n">server_</span><span class="p">.</span><span class="n">run</span><span class="p">();</span> <span class="p">}</span> </pre></div> </div> </div> <div class="section" id="want-to-learn-more"> <h1>Want to learn more?<a class="headerlink" href="#want-to-learn-more" title="Permalink to this headline">¶</a></h1> <blockquote> <div><ul class="simple"> <li><a class="reference internal" href="getting_started.html#getting-started"><span class="std std-ref">Take a look at the getting started guide</span></a></li> <li><a class="reference internal" href="examples.html#examples"><span class="std std-ref">Learn from some simple examples</span></a></li> <li><a class="reference internal" href="whats_new.html#whats-new"><span class="std std-ref">Find out what’s new</span></a></li> <li><a class="reference internal" href="reference.html#reference"><span class="std std-ref">Discover more through the full reference</span></a></li> <li><a class="reference internal" href="contents.html#contents"><span class="std std-ref">Full table of contents</span></a></li> </ul> </div></blockquote> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p class="last">Be aware that not all features are stable. The generic message design is under review and the URI and HTTP client implementation will continue to undergo refactoring. Future versions will include support for other network protocols.</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Getting cpp-netlib</a></li> <li><a class="reference internal" href="#c-network-library">C++ Network Library</a></li> <li><a class="reference internal" href="#hello-world">Hello, world!</a></li> <li><a class="reference internal" href="#want-to-learn-more">Want to learn more?</a></li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="contents.html" title="previous chapter">Contents</a></p> <h4>Next topic</h4> <p class="topless"><a href="whats_new.html" title="next chapter">What’s New</a></p> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <div><input type="text" name="q" /></div> <div><input type="submit" value="Go" /></div> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="whats_new.html" title="What’s New" >next</a></li> <li class="right" > <a href="contents.html" title="Contents" >previous</a> |</li> <li class="nav-item nav-item-0"><a href="contents.html">cpp-netlib v0.13.0</a> »</li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright 2008-2014, Glyn Matthews, Dean Michael Berris; 2013 Google, Inc.. Last updated on Nov 09, 2017. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.6. </div> </body> </html>