NetCpp  v0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
doxygen.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Evidence Srl - www.evidence.eu.com
3  *
4  * Boost Software License - Version 1.0 - August 17th, 2003
5  *
6  * Permission is hereby granted, free of charge, to any person or organization
7  * obtaining a copy of the software and accompanying documentation covered by
8  * this license (the "Software") to use, reproduce, display, distribute,
9  * execute, and transmit the Software, and to prepare derivative works of the
10  * Software, and to permit third-parties to whom the Software is furnished to
11  * do so, all subject to the following:
12  *
13  * The copyright notices in the Software and this entire statement, including
14  * the above license grant, this restriction and the following disclaimer,
15  * must be included in all copies of the Software, in whole or in part, and
16  * all derivative works of the Software, unless such copies or derivative
17  * works are solely in the form of machine-executable object code generated by
18  * a source language processor.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
23  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
24  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  * DEALINGS IN THE SOFTWARE.
27  */
28 
29 /**
30  *
31  * \htmlonly
32  * <br>
33  * <center>
34  * <img src="netcpp.png" width="300"></img><br>
35  * A tiny C++ network library
36  * </center>
37  * <br>
38  * \endhtmlonly
39  *
40  * @mainpage NetCpp
41  *
42  * @author Evidence Srl - <a href="http://www.evidence.eu.com" target="_blank">www.evidence.eu.com</a>
43  *
44  *
45  *
46  * <br>
47  * <br>
48  * <h1>Table of contents</h1>
49  * <ol>
50  * <li><a href="#rationale">Rationale</a>
51  * <li><a href="#requirements">Requirements</a>
52  * <li><a href="#build">How to build the library</a>
53  * <li><a href="#usage">Usage</a>
54  * <li><a href="#platforms">Supported platforms</a>
55  * <li><a href="#protocols">Adding further network protocols</a>
56  * <li><a href="#license">License</a>
57  * <li><a href="#support">Support</a>
58  * <li><a href="#todo">To do</a>
59  * </ol>
60  *
61  * <br>
62  * <br>
63  * <a name="rationale"><h2>Rationale</h2></a>
64  *
65  * The C++ standard library is known to be less comprehensive than the libraries
66  * traditionally available for other programming languages (e.g., Java, Python,
67  * etc.). The C++11 standard began to fill this gap by adding several features
68  * like support for multithreading, smart pointers, etc. Incredibly, however, a
69  * basic support for networking is still missing.
70  *
71  * During the last years, a number of C++ libraries have been proposed to have
72  * portable networking in C++, the most important being
73  * <a href="http://www.boost.org/libs/asio/" target="_blank">Boost::asio</a>
74  * and <a href="http://cpp-netlib.org" target="_blank">cpp-netlib</a>.
75  * However, we believe that the syntax of both these libraries is still more
76  * complicated than necessary.
77  * In particular, we believe that an ideal C++ networking library should be:
78  * <ul>
79  * <li> easy to use
80  * <li> easy to extend (either in terms of protocols and of supported architectures)
81  * </ul>
82  *
83  * NetCpp is a proof of concept to show that such a networking library can be
84  * made easily designed in C++. This tiny library has been built after the
85  * experience with the <a href="http://onposix.sourceforge.net" target="_blank">OnPosix library</a>.
86  * The syntax of the library is straightforward. The modular design given by the
87  * adoption of design patterns (i.e., <i>Abstract Factory</i> and <i>Bridge</i>) allows to easily
88  * add new protocols and supported platforms.
89  *
90  *
91  * <br>
92  * <br>
93  * <a name="requirements"><h2>Requirements</h2></a>
94  *
95  * To build NetCpp you need both:
96  * <ul>
97  * <li> <a href="http://www.cmake.org" target="_blank">cmake</a>
98  * <li> a C++11 compiler (e.g., gcc 4.7+ or LLVM 3.3+)
99  * </ul>
100  *
101  * Currently, only Posix systems (e.g., Linux). However, porting the library to
102  * different platforms is very easy thanks to its modular design.
103  *
104  *
105  * <br>
106  * <br>
107  * <a name="build"><h2>How to build the library</h2></a>
108  *
109  * Compile through the following commands:
110  *
111  * \code
112  * git clone https://github.com/claudioscordino/netcpp.git
113  * cd netcpp/build
114  * cmake ..
115  * make
116  * make install
117  * \endcode
118  *
119  * The library is put in the <i>netcpp/bin/</i> directory.
120  * The include files are available in the <i>netcpp/include/</i> directory.
121  *
122  * Documentation is generated through
123  * <a href="htttp://www.doxygen.org" target="_blank">Doxygen</a>.
124  * To generate the documentation, type:
125  *
126  * \code
127  * git clone https://github.com/claudioscordino/netcpp.git
128  * cd netcpp/build
129  * cmake ..
130  * make doc
131  * \endcode
132  *
133  * Start reading documentation by opening <i>doc/html/index.html</i>.
134  *
135  *
136  *
137  * <br>
138  * <br>
139  * <a name="usage"> <h2>Usage</h2></a>
140  *
141  * Usage of the library is straightforward:
142  *
143  * <h3>TCP client/server</h3>
144  *
145  * Example of TCP server:
146  * \code
147  * net::ip4::tcp::address addr (std::string("127.0.0.1"), 1234);
148  * net::ip4::tcp::server main_srv;
149  * net::ip4::tcp::server srv(&main_srv); // accept()
150  * srv.open(&addr);
151  * std::array<char, 5> buf;
152  * srv.receive(net::buffer(buf), 5);
153  * \endcode
154  *
155  * Example of TCP client:
156  * \code
157  * net::ip4::tcp::address addr (std::string("127.0.0.1"), 1234);
158  * net::ip4::tcp::client clt;
159  * clt.open(&addr);
160  * std::array<char, 5> b {'h', 'e', 'l', 'l', 'o'};
161  * clt.send(net::buffer(b), 3);
162  * \endcode
163  *
164  *
165  * <h3>UDP client/server</h3>
166  *
167  * Example of UDP server:
168  * \code
169  * net::ip4::udp::address addr (std::string("127.0.0.1"), 1234);
170  * net::ip4::udp::server srv;
171  * srv.open(&addr);
172  * std::array<char, 5> buf;
173  * srv.receive(net::buffer(buf), 5);
174  * \endcode
175  *
176  * Example of UDP client:
177  * \code
178  * net::ip4::udp::address addr (std::string("127.0.0.1"), 1234);
179  * net::ip4::udp::client clt;
180  * clt.open(&addr);
181  * std::array<char, 5> b {'h', 'e', 'l', 'l', 'o'};
182  * clt.send(net::buffer(b), 3);
183  * \endcode
184  *
185  * <br>
186  * <br>
187  * <a name="platforms"><h2>Supported platforms</h2></a>
188  *
189  * The library has a modular internal design which, thanks to the design patterns
190  * used, allows to decouple specific platform-dependent code (which is on the
191  * net::AbstractSystemSocket hierarchy) from any protocol design (which is on the
192  * net::AbstractSocket hierarchy). Modularity is especially given by the <i>Bridge</i>
193  * pattern, which allows two class hierarchies to vary independently.
194  *
195  * Thus, to add a new supported platform, you only need to:
196  * <ol>
197  * <li> inherit your platform-specific class from class net::AbstractSystemSocket.
198  * <li> change the concrete class allocated by net::createSocket().
199  * </ol>
200  * The build system, based on cmake, can be easily ported among all supported
201  * platforms.
202  *
203  * See the following picture to understand the collaboration between classes:
204  *
205  * <center>
206  * <img src="netcpp-architecture.png" width="800"></img>
207  * </center>
208  *
209  * <br>
210  * <br>
211  * <a name="protocols"><h2>Adding further network protocols</h2></a>
212  *
213  * To add a new protocol:
214  * <ul>
215  * <li> Create a proper namespace (like net::ip4::tcp)
216  * <li> Then, inside the new namespace:
217  * <ul>
218  * <li> Create an address class inheriting from class Address
219  * <li> Create server and client classes inheriting from class net::AbstractSocket
220  * </ul>
221  * </ul>
222  *
223  * <br>
224  * <br>
225  * <a name="license"><h2>License</h2></a>
226  *
227  * The library is under the
228  * <a href="http://www.boost.org/users/license.html" target="_blank">Boost license</a>.
229  * Read the LICENSE file for more information.
230  *
231  *
232  * <br>
233  * <br>
234  * <a name="support"><h2>Support</h2></a>
235  *
236  * For reporting bugs or proposing new patches, use
237  * <a href="https://github.com/claudioscordino/netcpp/issues" target="_blank">
238  * the issues link of GitHub</a>.
239  *
240  *
241  * <br>
242  * <br>
243  * <a name="todo"><h2>Todo</h2></a>
244  * <ul>
245  * <li> Add recvfrom and sendto for dgram connections
246  * <li> Add asynchronous operations
247  * </ul>
248  */
249