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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
<doc>
<title>Networking</title>
<!-- ************************************************************************* -->
<body>
<p>
This page documents tools built on top of the dlib <a href="api.html#sockets">sockets API</a>.
Therefore, all these tools are focused on providing some kind of higher level networking
abstraction or service.
</p>
</body>
<!-- ************************************************************************* -->
<menu width="150">
<top>
<section>
<name>Objects</name>
<item>linker</item>
<item>server</item>
<item>server_iostream</item>
<item>server_http</item>
<item>bridge</item>
<item>sockstreambuf</item>
<item>iosockstream</item>
</section>
<section>
<name>BSP</name>
<item>bsp_connect</item>
<item>bsp_listen</item>
<item>bsp_listen_dynamic_port</item>
<item>bsp_context</item>
</section>
</top>
</menu>
<!-- ************************************************************************* -->
<!-- ************************************************************************* -->
<!-- ************************************************************************* -->
<components>
<!-- ************************************************************************* -->
<component>
<name>linker</name>
<file>dlib/linker.h</file>
<spec_file>dlib/linker/linker_kernel_abstract.h</spec_file>
<description>
This object represents something that takes two connections and lets
them talk to each other. ie. any incoming data from one connection is
passed unaltered to the other and vice versa.
</description>
</component>
<!-- ************************************************************************* -->
<component>
<name>bridge</name>
<file>dlib/bridge.h</file>
<spec_file link="true">dlib/bridge/bridge_abstract.h</spec_file>
<description>
This object is a tool for bridging a <a href="other.html#pipe">pipe</a> object between
two network connected applications.
<p>
The bridge object is designed to link two pipes together as efficiently as
possible. To demonstrate its speed, I ran two experiments where a bridge was
used to connect a desktop PC to a laptop, both running Ubuntu 12.04 and
connected via gigabit ethernet. The first experiment is to test its bulk
transfer speed while the second experiment measures how many separate objects
the bridge can transfer each second.
</p>
<p>
In the first experiment, 1-megapixel images, represented with
<tt>array<rgb_pixel></tt> objects, were sent. The transfer rate was
112 megabytes/second, saturating the gigabit ethernet link. The second
experiment used a <tt>pipe<char></tt> and <tt>bridge</tt> to send individual
<tt>char</tt> variables over the network. In this experiment, I was able to
send 3.2 million objects a second (i.e. the receiving end was getting a char
back from pipe::dequeue() 3.2 million times each second).
</p>
<p>
For reference, these experiments were carried out on a desktop with a 2.67GHz
Intel Core-i7 CPU and a laptop with a 2.20GHz Intel Core-i7 CPU.
</p>
</description>
<examples>
<example>bridge_ex.cpp.html</example>
</examples>
</component>
<!-- ************************************************************************* -->
<component>
<name>bsp_connect</name>
<file>dlib/bsp.h</file>
<spec_file link="true">dlib/bsp/bsp_abstract.h</spec_file>
<description>
This function spawns a BSP job consisting of a number of network hosts
as well as the local host.
</description>
<examples>
<example>bsp_ex.cpp.html</example>
</examples>
</component>
<!-- ************************************************************************* -->
<component>
<name>bsp_listen</name>
<file>dlib/bsp.h</file>
<spec_file link="true">dlib/bsp/bsp_abstract.h</spec_file>
<description>
This function listens for a TCP connection from the <a href="#bsp_connect">bsp_connect</a> routine.
Once this connection is established, a user supplied function will be executed and it will
then be able to participate in a BSP computation as one of the processing
nodes.
</description>
<examples>
<example>bsp_ex.cpp.html</example>
</examples>
</component>
<!-- ************************************************************************* -->
<component>
<name>bsp_listen_dynamic_port</name>
<file>dlib/bsp.h</file>
<spec_file link="true">dlib/bsp/bsp_abstract.h</spec_file>
<description>
This function listens for a TCP connection from the <a href="#bsp_connect">bsp_connect</a> routine.
Once this connection is established, a user supplied function will be executed and it will
then be able to participate in a BSP computation as one of the processing
nodes. This function has the additional ability to select the listening TCP port
automatically from the set of available ports.
</description>
</component>
<!-- ************************************************************************* -->
<component>
<name>bsp_context</name>
<file>dlib/bsp.h</file>
<spec_file link="true">dlib/bsp/bsp_abstract.h</spec_file>
<description>
This is a tool used to implement algorithms using the Bulk Synchronous
Parallel (BSP) computing model. In particular, this object defines
the API used for communication between BSP jobs.
</description>
<examples>
<example>bsp_ex.cpp.html</example>
</examples>
</component>
<!-- ************************************************************************* -->
<component>
<name>server</name>
<file>dlib/server.h</file>
<spec_file>dlib/server/server_kernel_abstract.h</spec_file>
<description>
This object represents a server that listens on a port and spawns new
threads to handle each new connection. It also manages the connections
and threads for you.
</description>
<examples>
<example>sockets_ex.cpp.html</example>
</examples>
</component>
<!-- ************************************************************************* -->
<component>
<name>server_iostream</name>
<file>dlib/server.h</file>
<spec_file>dlib/server/server_iostream_abstract.h</spec_file>
<description>
This is an extension of the <a href="#server">server</a> object that redefines
the on_connect() function so that instead of giving you a connection object you
get an istream and ostream object.
</description>
<examples>
<example>server_iostream_ex.cpp.html</example>
</examples>
</component>
<!-- ************************************************************************* -->
<component>
<name>server_http</name>
<file>dlib/server.h</file>
<spec_file link="true">dlib/server/server_http_abstract.h</spec_file>
<description>
This is an extension of the <a href="#server_iostream">server_iostream</a> object which
turns it into a simple HTTP server.
</description>
<examples>
<example>server_http_ex.cpp.html</example>
</examples>
</component>
<!-- ************************************************************************* -->
<component>
<name>iosockstream</name>
<file>dlib/iosockstream.h</file>
<spec_file>dlib/iosockstream/iosockstream_abstract.h</spec_file>
<description>
This is an iostream object that reads/writes from a TCP network connection.
</description>
<examples>
<example>iosockstream_ex.cpp.html</example>
</examples>
</component>
<!-- ************************************************************************* -->
<component>
<name>sockstreambuf</name>
<file>dlib/sockstreambuf.h</file>
<spec_file>dlib/sockstreambuf/sockstreambuf_abstract.h</spec_file>
<description>
This object represents a stream buffer for connection objects. If you
are considering using this object then you should also take a look at
the <a href="#iosockstream">iosockstream</a>.
</description>
<examples>
<example>sockstreambuf_ex.cpp.html</example>
</examples>
</component>
<!-- ************************************************************************* -->
</components>
<!-- ************************************************************************* -->
</doc>