-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
209 lines (192 loc) · 13.3 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!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.10.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.10.0',
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.10.0" href="#" />
<link rel="next" title="What’s New" href="whats_new.html" />
<link rel="prev" title="Contents" href="contents.html" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Neuton&subset=latin" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Nobile:regular,italic,bold,bolditalic&subset=latin" type="text/css" media="screen" charset="utf-8" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="_static/ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
</head>
<body>
<div class="related">
<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><a href="contents.html">cpp-netlib v0.10.0</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<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 <tt class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></tt> 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 <tt class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></tt> is tagged as cpp-netlib-0.10.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><tt class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></tt> 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 <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="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"><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 class="sphinxsidebar">
<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">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<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><a href="contents.html">cpp-netlib v0.10.0</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2008-2013, Glyn Matthews, Dean Michael Berris; 2013 Google, Inc..
Last updated on Jul 05, 2013.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2b1.
</div>
</body>
</html>