1 /** \mainpage The SENF Socket Library
3 The Socket library provides a high level and object oriented
4 abstraction of the BSD socket API. The abstraction is based on
7 \li The basic visible interface is a handle object
8 (senf::FileHandle and it's derived classes)
9 \li The socket interface relies on a policy framework to configure
11 \li The rest of the socket API is accessible using a classic
12 inheritance hierarchy of protocol classes
14 The handle/body architecture provides automatic reference counted
15 management of socket instances, the policy framework provides
16 highly efficient access to the most important socket functions
17 (like reading and writing) and the inheritance hierarchy provides
18 convenient access to the multitude of special and protocol
26 /** \page usage Using the Socket Library
28 \section socket_handle The socket handle
30 Whenever you use the socket library, what you will be dealing with
31 are senf::FileHandle derived instances. The socket library relies
32 on reference counting to automatically manage the underlying
33 socket representation. This frees you of having to manage the
34 socket lifetime explicitly.
36 \section socket_hierarchy The FileHandle hierarchy
38 \image html FhHierarchy.png
40 The senf::FileHandle class is the base of a hierarchy of socket
41 handle classes (realized as templates). These classes provide an
42 interface to the complete socket API. While going down the
43 inheritance hierarchy, the interface will be more and more
46 The most complete interface is provided by
47 senf::ProtocolClientSocketHandle and
48 senf::ProtocolServerSocketHandle. The template Arguments specifies
49 the Protocol class of the underlying socket type. These are the
50 \e only classes having public constructors and are therefore the
51 only classes, which may be created by the library user. You will
52 normally use these classes by naming a specific socket typedef
53 (e.g. senf::TCPv4ClientSocketHandle).
55 However, to aid writing flexible and generic code, the socket
56 library provides the senf::ClientSocketHandle and
57 senf::ServerSocketHandle class templates. These templates
58 implement a family of closely related classes based on the
59 specification of the socket policy. This policy specification may
60 be \e incomplete (see below). Instances of
61 senf::ClientSocketHandle/senf::ServerSocketHandle can be assigned
62 and converted to different ClientSocketHandle/ServerSocketHandle
63 types as long as the policy specifications are compatible.
65 \attention It is very important, to (almost) always pass the socket
66 handle <em>by value</em>. The socket handle is a very lightweight
67 class and designed to be used like an ordinary built-in type. This
68 is very important in combination with the policy interface.
70 \section policy_framework The policy framework
72 \image html SocketPolicy.png
74 The policy framework conceptually implements a list of parallel
75 inheritance hierarchies each covering a specific interface aspect
76 of the socket handle. The socket handle itself only provides
77 minimal functionality. All further functionality is relayed to a
78 policy class, or more precisely, to a group of policy classes, one
79 for each policy axis. The policy axis are
82 <dt><em>addressingPolicy</em></dt>
83 <dd>configures, whether a socket is
84 addressable and if so, configures the address type</dd>
86 <dt><em>framingPolicy</em></dt>
87 <dd>configures the type of framing the socket provides: either no
88 framing providing a simple i/o stream or packet framing</dd>
90 <dt><em>communicationPolicy</em></dt>
91 <dd>configures,if and how the communication partner is
94 <dt><em>readPolicy</em></dt>
95 <dd>configures the readability of the socket</dd>
97 <dt><em>writePolicy</em></dt>
98 <dd>configures the writability of the socket</dd>
100 <dt><em>bufferingPolicy</em></dt>
101 <dd>configures, if and how buffering is configured for a socket</dd>
104 Every Policy value is identified by a class type. The policy types
105 themselves built an inheritance hierarchy for each policy
106 axis. For each policy axis, the root of this tree is the class
107 named '<tt>(axis name)Base</tt>' (e.g. \p FramingPolicyBase or \p
108 CommunicationPolicyBase) which is aliased to '<tt>Unspecified(axis
109 name)</tt>' (e.g. \p UnspecifiedFramingPolicy or \p
110 UnspecifiedCommunicationPolicy).
112 The senf::SocketPolicy template combines a set of policy classes,
113 one for each policy axis. Together, they define the behavior of a
114 socket handle. The socket handle instances do net implement any
115 socket functionality themselves, instead defering the
116 implementation to the socket classes. The interface is therefore
117 \e not implemented using virtual members, all important socket
118 functions can be inlined by the compiler to create highly
121 Two SocketPolicy instances are considered compatible, if all
122 policy axis are compatible. A policy axis is compatible, if one
123 policy class is either the same as the other or derived from
124 it. Two SocketHandle instances can be converted into each other,
125 as long as the SocketPolicies are compatible.
127 \section policy_interface The policy interface
129 The socket handle classes and templates only implement the most
130 important socket API methods. To access the complete API, the
131 protocol interface is provided. Access to the protocol interface
132 is only possible via senf::ProtocolClientSocketHandle and
133 senf::ProtocolServerSocketHandle which have the necessary \c
134 protocol() member. This member returns a reference to the protocol
135 class instance which contains members covering all the API
136 function snot found in the SocketHandle interface. The protocol
137 interface is specific to the protocol. It's implementation is
138 quite free. Every protocol class will define the complete and
139 specific socket policy of it's socket handle.
142 /** \page extend Extending the Library
145 /** \page implementation Implementation notes
147 \image html SocketLibrary-classes.png
155 // ispell-local-dictionary: "american"