forked from cpp-netlib/cpp-netlib.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
187 lines (163 loc) · 12.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!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.9.3</title>
<link rel="stylesheet" href="_static/cpp-netlib.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.9.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</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="top" title="cpp-netlib v0.9.3" href="#" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19815738-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div class="document">
<div id="custom-doc" class="">
<div id="hd">
<h1><a href="#">cpp-netlib v0.9.3</a></h1>
<div id="global-nav">
<a title="Home page" href="#">Home</a> |
<a title="Table of contents" href="contents.html">Table of contents</a> |
<a title="What's new" href="whats_new.html">What's new</a> |
<a title="Getting started" href="getting_started.html">Getting started</a> |
<a title="Examples" href="examples.html">Examples</a> |
<a title="In depth" href="in_depth.html">In depth</a> |
<a title="Reference" href="reference.html">Reference</a>
</div>
<div class="nav">
<a title="cpp-netlib v0.9.3" href="#" accesskey="U">up</a></div>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<div class="yui-g" id="index">
<p class="rubric" id="index">Straightforward network programming in modern C++</p>
<div class="section" id="cpp-netlib-getting-cpp-netlib">
<h1>Getting cpp-netlib<a class="headerlink" href="#cpp-netlib-getting-cpp-netlib" title="Permalink to this headline">¶</a></h1>
<p><strong>Download</strong></p>
<p>You can download the latest releases of the library at:</p>
<blockquote>
<div><a class="reference external" href="http://github.com/cpp-netlib/cpp-netlib/downloads">http://github.com/cpp-netlib/cpp-netlib/downloads</a></div></blockquote>
<p>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="cpp-netlib-boost">
<h1>Boost<a class="headerlink" href="#cpp-netlib-boost" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></tt> is being developed for eventual submission to <a class="reference external" href="http://www.boost.org/">Boost</a>.</p>
<img alt="_images/boost.png" class="align-left" src="_images/boost.png" />
</div>
<div class="section" id="cpp-netlib-c-network-library">
<h1>C++ Network Library<a class="headerlink" href="#cpp-netlib-c-network-library" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></tt> is a library 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>
<p>It is developed by people linked to the <a class="reference external" href="http://www.boost.org/">Boost</a> community and will soon
be submitted for review into Boost. A presentation about
<tt class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></tt> was given at <a class="reference external" href="http://www.boostcon.com/">BoostCon 2010</a>, for which the
<a class="reference external" href="http://www.filetolink.com/b0e89d06">slides</a> and the <a class="reference external" href="http://github.com/downloads/mikhailberis/cpp-netlib-boostcon-paper/cpp-netlib.pdf">paper</a> can be found on-line.</p>
</div>
<div class="section" id="cpp-netlib-hello-world">
<h1>Hello, world!<a class="headerlink" href="#cpp-netlib-hello-world" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></tt> 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-c++"><div class="highlight"><pre><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-c++"><div class="highlight"><pre><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="n">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="n">server_</span><span class="p">(</span><span class="s">"0.0.0.0"</span><span class="p">,</span> <span class="s">"8000"</span><span class="p">,</span> <span class="n">handler_</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="cpp-netlib-want-to-learn-more">
<h1>Want to learn more?<a class="headerlink" href="#cpp-netlib-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"><em>Take a look at the getting started guide</em></a></li>
<li><a class="reference internal" href="examples.html#examples"><em>Learn from some simple examples</em></a></li>
<li><a class="reference internal" href="whats_new.html#whats-new"><em>Find out what’s new</em></a></li>
<li><a class="reference internal" href="in_depth.html#in-depth"><em>Study the library in more depth</em></a></li>
<li><a class="reference internal" href="reference.html#reference"><em>Discover more through the full reference</em></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>
<div id="ft">
<div class="nav">
<a title="cpp-netlib v0.9.3" href="#" accesskey="U">up</a></div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
documentation automatically generated by <a href="http://sphinx.pocoo.org">Sphinx</a> | style mostly stolen from <a href="http://lettuce.it">lettuce.it</a>
</div>
</body>
</html>